Better diagnostics + basic recursion detection in memoized functions
This commit is contained in:
@@ -277,13 +277,13 @@ public class LockBasedStorageManager implements StorageManager {
|
|||||||
try {
|
try {
|
||||||
V typedValue = compute.invoke(input);
|
V typedValue = compute.invoke(input);
|
||||||
Object oldValue = cache.put(input, WrappedValues.escapeNull(typedValue));
|
Object oldValue = cache.put(input, WrappedValues.escapeNull(typedValue));
|
||||||
assert oldValue == null : "Race condition detected";
|
assert oldValue == null : "Race condition or recursion detected. Old value is " + oldValue;
|
||||||
|
|
||||||
return typedValue;
|
return typedValue;
|
||||||
}
|
}
|
||||||
catch (Throwable throwable) {
|
catch (Throwable throwable) {
|
||||||
Object oldValue = cache.put(input, WrappedValues.escapeThrowable(throwable));
|
Object oldValue = cache.put(input, WrappedValues.escapeThrowable(throwable));
|
||||||
assert oldValue == null : "Race condition detected";
|
assert oldValue == null : "Race condition or recursion detected. Old value is " + oldValue;
|
||||||
|
|
||||||
throw ExceptionUtils.rethrow(throwable);
|
throw ExceptionUtils.rethrow(throwable);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user