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,11 +418,15 @@ 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) {
try {
Object _value = postComputeCache.get(); Object _value = postComputeCache.get();
if (!(_value instanceof NotValue)) { if (!(_value instanceof NotValue)) {
// This thread is counting the value so allow an early publication // This thread is counting the value so allow an early publication
return WrappedValues.unescapeThrowable(_value); return WrappedValues.unescapeThrowable(_value);
} }
} finally {
postComputeCache.remove();
}
} }
return super.invoke(); return super.invoke();
@@ -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();
} }
} }