Skip to content

Commit 20123fb

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 <vpotucek@me.com>
1 parent b174bdb commit 20123fb

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

junit-platform-engine/src/main/java/org/junit/platform/engine/support/store/NamespacedHierarchicalStore.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import java.util.function.Supplier;
3131

3232
import org.apiguardian.api.API;
33-
import org.jspecify.annotations.NonNull;
3433
import org.jspecify.annotations.Nullable;
3534
import org.junit.platform.commons.util.Preconditions;
3635
import org.junit.platform.commons.util.UnrecoverableExceptions;
@@ -248,7 +247,7 @@ public <K, V> Object computeIfAbsent(N namespace, K key, Function<? super K, ? e
248247
var value = storedValues.compute(compositeKey, (__, currentValue) ->
249248
currentValue != null && !currentValue.equals(storedValue)
250249
? currentValue
251-
: getStoredValue(key, defaultCreator));
250+
: storeNewValue(key, defaultCreator));
252251
try {
253252
return requireNonNull(value.evaluate());
254253
}
@@ -262,7 +261,7 @@ public <K, V> Object computeIfAbsent(N namespace, K key, Function<? super K, ? e
262261
return result;
263262
}
264263

265-
private <K, V> StoredValue getStoredValue(K key, Function<? super K, ? extends V> defaultCreator) {
264+
private <K, V> StoredValue storeNewValue(K key, Function<? super K, ? extends V> defaultCreator) {
266265
rejectIfClosed();
267266
return newStoredValue(new MemoizingSupplier(() -> {
268267
rejectIfClosed();

0 commit comments

Comments
 (0)