@@ -51,7 +51,6 @@ public class EVCacheBulkGetFuture<T> extends BulkGetFuture<T> {
5151 private static final Logger log = LoggerFactory .getLogger (EVCacheBulkGetFuture .class );
5252 private final Map <String , Future <T >> rvMap ;
5353 private final Collection <Operation > ops ;
54- private final Operation [] opsArray ;
5554 private final CountDownLatch latch ;
5655 private final long start ;
5756 private final EVCacheClient client ;
@@ -61,7 +60,6 @@ public EVCacheBulkGetFuture(Map<String, Future<T>> m, Collection<Operation> getO
6160 super (m , getOps , l , service );
6261 rvMap = m ;
6362 ops = getOps ;
64- opsArray = ops .toArray (new Operation [0 ]);
6563 latch = l ;
6664 this .start = System .currentTimeMillis ();
6765 this .client = client ;
@@ -73,7 +71,7 @@ public Map<String, T> getSome(long to, TimeUnit unit, boolean throwException, bo
7371 assert operationStates != null ;
7472
7573 // Note: The latch here is counterintuitive. Based on the implementation in EVCacheMemcachedClient.asyncGetBulk(),
76- // the latch count is set to 1 no matter the chunk size and only decrement when pendingChunks counts down to 0.
74+ // the latch count is set to 1 no matter the chunk size (when > 0) and only decrement when pendingChunks counts down to 0.
7775 boolean allCompleted = latch .await (to , unit );
7876 if (log .isDebugEnabled ()) log .debug ("Took " + (System .currentTimeMillis () - start )+ " to fetch " + rvMap .size () + " keys from " + client );
7977 long pauseDuration = -1 ;
@@ -130,6 +128,7 @@ public Map<String, T> getSome(long to, TimeUnit unit, boolean throwException, bo
130128 if (state == null ) {
131129 // Operation not yet signaled completion (cancel should still trigger completion) ==> latch timed out
132130 // This also indicates allCompleted == false because the latch count wouldn't have drop to 0.
131+ Operation [] opsArray = ops .toArray (new Operation [0 ]);
133132 Operation op = opsArray [i ];
134133 op .timeOut ();
135134 MemcachedConnection .opTimedOut (op );
@@ -245,6 +244,7 @@ public void handleBulkException() {
245244 SingleOperationState state = operationStates .get (i );
246245
247246 if (state == null ) {
247+ Operation [] opsArray = ops .toArray (new Operation [0 ]);
248248 Operation op = opsArray [i ];
249249 op .timeOut ();
250250 MemcachedConnection .opTimedOut (op );
@@ -287,9 +287,10 @@ public Single<Map<String, T>> getSome(long to, TimeUnit units, boolean throwExce
287287 try {
288288 for (int i = 0 ; i < operationStates .length (); i ++) {
289289 SingleOperationState state = operationStates .get (i );
290- Operation op = opsArray [i ];
291290
292291 if (state == null ) {
292+ Operation [] opsArray = ops .toArray (new Operation [0 ]);
293+ Operation op = opsArray [i ];
293294 op .timeOut ();
294295 MemcachedConnection .opTimedOut (op );
295296 // Should we throw when timeout?
@@ -305,7 +306,6 @@ public Single<Map<String, T>> getSome(long to, TimeUnit units, boolean throwExce
305306
306307 for (int i = 0 ; i < operationStates .length (); i ++) {
307308 SingleOperationState state = operationStates .get (i );
308- Operation op = opsArray [i ];
309309
310310 // state == null always means timed out and was handled.
311311 if (state != null ) {
0 commit comments