@@ -331,6 +331,8 @@ public void testSequentialAccess() throws InterruptedException {
331
331
latch .await ();
332
332
}
333
333
334
+ executorService .shutdownNow ();
335
+
334
336
// Verify the final value of "foo" in Redis
335
337
String finalValue = control .get ("foo" );
336
338
assertEquals (threadCount * iterations , Integer .parseInt (finalValue ));
@@ -368,6 +370,8 @@ public void testConcurrentAccessWithStats() throws InterruptedException {
368
370
latch .await ();
369
371
}
370
372
373
+ executorService .shutdownNow ();
374
+
371
375
CacheStats stats = testCache .getStats ();
372
376
assertEquals (threadCount * iterations , stats .getMissCount () + stats .getHitCount ());
373
377
assertEquals (stats .getMissCount (), stats .getLoadCount ());
@@ -385,26 +389,28 @@ public void testMaxSize() throws InterruptedException {
385
389
// Create the shared mock instance of cache
386
390
TestCache testCache = new TestCache (maxSize , map , DefaultCacheable .INSTANCE );
387
391
388
- // Submit multiple threads to perform concurrent operations
389
- CountDownLatch latch = new CountDownLatch (threadCount );
390
- for (int i = 0 ; i < threadCount ; i ++) {
391
- executorService .submit (() -> {
392
- try (JedisPooled jedis = new JedisPooled (endpoint .getHostAndPort (), clientConfig .get (), testCache )) {
393
- for (int j = 0 ; j < iterations ; j ++) {
394
- // Simulate continious get and update operations and consume invalidation events meanwhile
395
- assertEquals ("OK" , jedis .set ("foo" + j , "foo" + j ));
396
- jedis .get ("foo" + j );
392
+ try (JedisPooled jedis = new JedisPooled (endpoint .getHostAndPort (), clientConfig .get (), testCache )) {
393
+ // Submit multiple threads to perform concurrent operations
394
+ CountDownLatch latch = new CountDownLatch (threadCount );
395
+ for (int i = 0 ; i < threadCount ; i ++) {
396
+ executorService .submit (() -> {
397
+ try {
398
+ for (int j = 0 ; j < iterations ; j ++) {
399
+ // Simulate continious get and update operations and consume invalidation events meanwhile
400
+ assertEquals ("OK" , jedis .set ("foo" + j , "foo" + j ));
401
+ jedis .get ("foo" + j );
402
+ }
403
+ } finally {
404
+ latch .countDown ();
397
405
}
398
- } catch (Exception e ) {
399
- e .printStackTrace ();
400
- } finally {
401
- latch .countDown ();
402
- }
403
- });
406
+ });
407
+ }
408
+
409
+ // wait for all threads to complete
410
+ latch .await ();
404
411
}
405
412
406
- // wait for all threads to complete
407
- latch .await ();
413
+ executorService .shutdownNow ();
408
414
409
415
CacheStats stats = testCache .getStats ();
410
416
0 commit comments