Skip to content

Commit fcd6ca2

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 20123fb commit fcd6ca2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,9 @@ public <K, V> Object computeIfAbsent(N namespace, K key, Function<? super K, ? e
245245
var result = StoredValue.evaluateIfNotNull(storedValue);
246246
if (result == null) {
247247
var value = storedValues.compute(compositeKey, (__, currentValue) ->
248-
currentValue != null && !currentValue.equals(storedValue)
249-
? currentValue
250-
: storeNewValue(key, defaultCreator));
248+
currentValue == null || currentValue.equals(storedValue)
249+
? storeNewValue(key, defaultCreator)
250+
: currentValue);
251251
try {
252252
return requireNonNull(value.evaluate());
253253
}

0 commit comments

Comments
 (0)