@@ -91,7 +91,6 @@ class HostConnectionPool implements Connection.Owner {
9191 @ VisibleForTesting Set <Connection >[] trash ;
9292
9393 private Queue <PendingBorrow >[] pendingBorrows ;
94- private AtomicInteger [] pendingBorrowCountByShard ;
9594 final AtomicInteger pendingBorrowCount = new AtomicInteger ();
9695
9796 private AtomicInteger [] scheduledForCreation ;
@@ -211,12 +210,10 @@ public void tempBlockAdvShardAwareness(long millis) {
211210 }
212211
213212 int pendingBorrowCountForShard (int shardId ) {
214- if (pendingBorrowCountByShard == null
215- || shardId < 0
216- || shardId >= pendingBorrowCountByShard .length ) {
213+ if (pendingBorrows == null || shardId < 0 || shardId >= pendingBorrows .length ) {
217214 return OperationTimedOutException .UNAVAILABLE ;
218215 }
219- return pendingBorrowCountByShard [shardId ].get ();
216+ return pendingBorrows [shardId ].size ();
220217 }
221218
222219 int openConnectionCountForShard (int shardId ) {
@@ -331,13 +328,11 @@ ListenableFuture<Void> initAsyncWithConnection(Connection reusedConnection) {
331328 open = new AtomicInteger [shardsCount ];
332329 trash = new Set [shardsCount ];
333330 pendingBorrows = new Queue [shardsCount ];
334- pendingBorrowCountByShard = new AtomicInteger [shardsCount ];
335331 for (int i = 0 ; i < shardsCount ; ++i ) {
336332 this .connections [i ] = new CopyOnWriteArrayList <Connection >();
337333 scheduledForCreation [i ] = new AtomicInteger ();
338334 open [i ] = new AtomicInteger ();
339335 trash [i ] = new CopyOnWriteArraySet <Connection >();
340- pendingBorrowCountByShard [i ] = new AtomicInteger ();
341336 pendingBorrows [i ] = new ConcurrentLinkedQueue <PendingBorrow >();
342337 }
343338
@@ -653,7 +648,6 @@ private ListenableFuture<Connection> enqueue(
653648 }
654649
655650 PendingBorrow pendingBorrow = new PendingBorrow (timeout , unit , timeoutsExecutor );
656- pendingBorrowCountByShard [shardId ].incrementAndGet ();
657651 pendingBorrows [shardId ].add (pendingBorrow );
658652
659653 // If we raced with shutdown, make sure the future will be completed. This has no effect if it
@@ -718,7 +712,6 @@ private void dequeue(final Connection connection) {
718712 connection .inFlight .decrementAndGet ();
719713 } else {
720714 pendingBorrowCount .decrementAndGet ();
721- pendingBorrowCountByShard [connection .shardId ()].decrementAndGet ();
722715 // Ensure that the keyspace set on the connection is the one set on the pool state, in the
723716 // general case it will be.
724717 ListenableFuture <Connection > setKeyspaceFuture =
0 commit comments