Clean using thread local in all threads (KT-28940)

This commit is contained in:
Nikolay Krasko
2019-10-28 11:48:44 +03:00
parent 587b0de2b8
commit 02f9b255e6
@@ -418,10 +418,14 @@ public class LockBasedStorageManager implements StorageManager {
public T invoke() {
ThreadLocal<Object> postComputeCache = valuePostCompute;
if (postComputeCache != null) {
Object _value = postComputeCache.get();
if (!(_value instanceof NotValue)) {
// This thread is counting the value so allow an early publication
return WrappedValues.unescapeThrowable(_value);
try {
Object _value = postComputeCache.get();
if (!(_value instanceof NotValue)) {
// This thread is counting the value so allow an early publication
return WrappedValues.unescapeThrowable(_value);
}
} finally {
postComputeCache.remove();
}
}
@@ -444,8 +448,8 @@ public class LockBasedStorageManager implements StorageManager {
valuePostCompute = postComputeCache;
doPostCompute(value);
} finally {
postComputeCache.remove();
valuePostCompute = null;
postComputeCache.remove();
}
}