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() { public T invoke() {
ThreadLocal<Object> postComputeCache = valuePostCompute; ThreadLocal<Object> postComputeCache = valuePostCompute;
if (postComputeCache != null) { if (postComputeCache != null) {
Object _value = postComputeCache.get(); try {
if (!(_value instanceof NotValue)) { Object _value = postComputeCache.get();
// This thread is counting the value so allow an early publication if (!(_value instanceof NotValue)) {
return WrappedValues.unescapeThrowable(_value); // 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; valuePostCompute = postComputeCache;
doPostCompute(value); doPostCompute(value);
} finally { } finally {
postComputeCache.remove();
valuePostCompute = null; valuePostCompute = null;
postComputeCache.remove();
} }
} }