Skip to content

Commit f9b7dfb

Browse files
author
Vincent Potucek
committed
[tryout fix] concurrency bug in NamespacedHierarchicalStore#computeIfAbsent(Object, Object, Function) junit-team#5171 junit-team#5209
Signed-off-by: Vincent Potucek <[email protected]>
1 parent 11ea2c0 commit f9b7dfb

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

platform-tests/src/test/java/org/junit/platform/engine/support/store/NamespacedHierarchicalStoreTests.java

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -719,20 +719,18 @@ void getOrComputeIfAbsentDoesNotDeadlockWithCollidingKeys() throws Exception {
719719
var latch1 = new CountDownLatch(1);
720720
var latch2 = new CountDownLatch(1);
721721

722-
var thread1 = new Thread(() -> {
723-
store.getOrComputeIfAbsent("ns", new CollidingKey(1), key -> {
724-
latch1.countDown();
725-
try {
726-
// Wait for second thread to start its computation
727-
latch2.await();
728-
}
729-
catch (InterruptedException e) {
730-
Thread.currentThread().interrupt();
731-
throw new RuntimeException(e);
732-
}
733-
return "value1";
734-
});
735-
});
722+
var thread1 = new Thread(() -> store.getOrComputeIfAbsent("ns", new CollidingKey(1), key -> {
723+
latch1.countDown();
724+
try {
725+
// Wait for second thread to start its computation
726+
latch2.await();
727+
}
728+
catch (InterruptedException e) {
729+
Thread.currentThread().interrupt();
730+
throw new RuntimeException(e);
731+
}
732+
return "value1";
733+
}));
736734

737735
var thread2 = new Thread(() -> {
738736
try {

0 commit comments

Comments
 (0)