@@ -107,6 +107,7 @@ void testLock(RedisLockType testRedisLockType) {
107
107
}
108
108
registry .expireUnusedOlderThan (-1000 );
109
109
assertThat (getRedisLockRegistryLocks (registry )).isEmpty ();
110
+ registry .destroy ();
110
111
}
111
112
112
113
@ ParameterizedTest
@@ -126,6 +127,7 @@ void testLockInterruptibly(RedisLockType testRedisLockType) throws Exception {
126
127
}
127
128
registry .expireUnusedOlderThan (-1000 );
128
129
assertThat (getRedisLockRegistryLocks (registry )).isEmpty ();
130
+ registry .destroy ();
129
131
}
130
132
131
133
@ ParameterizedTest
@@ -153,6 +155,7 @@ void testReentrantLock(RedisLockType testRedisLockType) {
153
155
}
154
156
registry .expireUnusedOlderThan (-1000 );
155
157
assertThat (getRedisLockRegistryLocks (registry )).isEmpty ();
158
+ registry .destroy ();
156
159
}
157
160
158
161
@ ParameterizedTest
@@ -180,6 +183,7 @@ void testReentrantLockInterruptibly(RedisLockType testRedisLockType) throws Exce
180
183
}
181
184
registry .expireUnusedOlderThan (-1000 );
182
185
assertThat (getRedisLockRegistryLocks (registry )).isEmpty ();
186
+ registry .destroy ();
183
187
}
184
188
185
189
@ ParameterizedTest
@@ -207,6 +211,7 @@ void testTwoLocks(RedisLockType testRedisLockType) throws Exception {
207
211
}
208
212
registry .expireUnusedOlderThan (-1000 );
209
213
assertThat (getRedisLockRegistryLocks (registry )).isEmpty ();
214
+ registry .destroy ();
210
215
}
211
216
212
217
@ ParameterizedTest
@@ -238,6 +243,7 @@ void testTwoThreadsSecondFailsToGetLock(RedisLockType testRedisLockType) throws
238
243
assertThat (((Exception ) ise ).getMessage ()).contains ("You do not own lock at" );
239
244
registry .expireUnusedOlderThan (-1000 );
240
245
assertThat (getRedisLockRegistryLocks (registry )).isEmpty ();
246
+ registry .destroy ();
241
247
}
242
248
243
249
@ ParameterizedTest
@@ -277,6 +283,7 @@ void testTwoThreads(RedisLockType testRedisLockType) throws Exception {
277
283
assertThat (locked .get ()).isTrue ();
278
284
registry .expireUnusedOlderThan (-1000 );
279
285
assertThat (getRedisLockRegistryLocks (registry )).isEmpty ();
286
+ registry .destroy ();
280
287
}
281
288
282
289
@ ParameterizedTest
@@ -326,6 +333,8 @@ void testTwoThreadsDifferentRegistries(RedisLockType testRedisLockType) throws E
326
333
registry2 .expireUnusedOlderThan (-1000 );
327
334
assertThat (getRedisLockRegistryLocks (registry1 )).isEmpty ();
328
335
assertThat (getRedisLockRegistryLocks (registry2 )).isEmpty ();
336
+ registry1 .destroy ();
337
+ registry2 .destroy ();
329
338
}
330
339
331
340
@ ParameterizedTest
@@ -355,6 +364,7 @@ void testTwoThreadsWrongOneUnlocks(RedisLockType testRedisLockType) throws Excep
355
364
assertThat (((Exception ) ise ).getMessage ()).contains ("You do not own lock at" );
356
365
registry .expireUnusedOlderThan (-1000 );
357
366
assertThat (getRedisLockRegistryLocks (registry )).isEmpty ();
367
+ registry .destroy ();
358
368
}
359
369
360
370
@ ParameterizedTest
@@ -371,6 +381,8 @@ void testExpireTwoRegistries(RedisLockType testRedisLockType) throws Exception {
371
381
waitForExpire ("foo" );
372
382
assertThat (lock2 .tryLock ()).isTrue ();
373
383
assertThat (lock1 .tryLock ()).isFalse ();
384
+ registry1 .destroy ();
385
+ registry2 .destroy ();
374
386
}
375
387
376
388
@ ParameterizedTest
@@ -384,6 +396,7 @@ void testExceptionOnExpire(RedisLockType testRedisLockType) throws Exception {
384
396
assertThatIllegalStateException ()
385
397
.isThrownBy (lock1 ::unlock )
386
398
.withMessageContaining ("Lock was released in the store due to expiration." );
399
+ registry .destroy ();
387
400
}
388
401
389
402
@@ -422,6 +435,9 @@ void testEquals(RedisLockType testRedisLockType) {
422
435
lock2 .lock ();
423
436
lock1 .unlock ();
424
437
lock2 .unlock ();
438
+ registry1 .destroy ();
439
+ registry2 .destroy ();
440
+ registry3 .destroy ();
425
441
}
426
442
427
443
@ ParameterizedTest
@@ -446,6 +462,7 @@ void testThreadLocalListLeaks(RedisLockType testRedisLockType) {
446
462
lock .unlock ();
447
463
}
448
464
assertThat (getRedisLockRegistryLocks (registry )).hasSize (10 );
465
+ registry .destroy ();
449
466
}
450
467
451
468
@ ParameterizedTest
@@ -468,6 +485,7 @@ void testExpireNotChanged(RedisLockType testRedisLockType) throws Exception {
468
485
result .get ();
469
486
assertThat (getExpire (registry , "foo" )).isEqualTo (expire );
470
487
lock .unlock ();
488
+ registry .destroy ();
471
489
}
472
490
473
491
@ ParameterizedTest
@@ -510,6 +528,7 @@ void concurrentObtainCapacityTest(RedisLockType testRedisLockType) throws Interr
510
528
511
529
registry .expireUnusedOlderThan (-1000 );
512
530
assertThat (getRedisLockRegistryLocks (registry )).isEmpty ();
531
+ registry .destroy ();
513
532
}
514
533
515
534
@ ParameterizedTest
@@ -558,7 +577,8 @@ void concurrentObtainRemoveOrderTest(RedisLockType testRedisLockType) throws Int
558
577
executorService .awaitTermination (5 , TimeUnit .SECONDS );
559
578
560
579
assertThat (getRedisLockRegistryLocks (registry )).containsKeys (
561
- remainLockCheckQueue .toArray (new String [remainLockCheckQueue .size ()]));
580
+ remainLockCheckQueue .toArray (new String [0 ]));
581
+ registry .destroy ();
562
582
}
563
583
564
584
@ ParameterizedTest
@@ -613,7 +633,8 @@ void concurrentObtainAccessRemoveOrderTest(RedisLockType testRedisLockType) thro
613
633
executorService .awaitTermination (5 , TimeUnit .SECONDS );
614
634
615
635
assertThat (getRedisLockRegistryLocks (registry )).containsKeys (
616
- remainLockCheckQueue .toArray (new String [remainLockCheckQueue .size ()]));
636
+ remainLockCheckQueue .toArray (new String [0 ]));
637
+ registry .destroy ();
617
638
}
618
639
619
640
@ ParameterizedTest
@@ -642,6 +663,7 @@ void setCapacityTest(RedisLockType testRedisLockType) {
642
663
registry .obtain ("foo:5" );
643
664
assertThat (getRedisLockRegistryLocks (registry )).hasSize (4 );
644
665
assertThat (getRedisLockRegistryLocks (registry )).containsKeys ("foo:3" , "foo:4" , "foo:5" );
666
+ registry .destroy ();
645
667
}
646
668
647
669
@ ParameterizedTest
@@ -690,6 +712,8 @@ void twoRedisLockRegistryTest(RedisLockType testRedisLockType) throws Interrupte
690
712
691
713
assertThat (future1 ).isNotCompletedExceptionally ();
692
714
assertThat (future2 ).isNotCompletedExceptionally ();
715
+ registry1 .destroy ();
716
+ registry2 .destroy ();
693
717
}
694
718
695
719
@ ParameterizedTest
@@ -782,6 +806,9 @@ void earlyWakeUpTest(RedisLockType testRedisLockType) throws InterruptedExceptio
782
806
assertThat (awaitTimeout .await (1 , TimeUnit .SECONDS )).isFalse ();
783
807
assertThat (expectOne .get ()).isEqualTo (1 );
784
808
executorService .shutdown ();
809
+ registry1 .destroy ();
810
+ registry2 .destroy ();
811
+ registry3 .destroy ();
785
812
}
786
813
787
814
private Long getExpire (RedisLockRegistry registry , String lockKey ) {
0 commit comments