concurrency bug: cached value can be set to null while the other thread has already computed it in the meantime. This leads to multiple unnecessary re-computations.

This commit is contained in:
Alexey Kudravtsev
2017-02-16 10:28:14 +03:00
parent 2884a40691
commit 4c471669ee
@@ -59,9 +59,12 @@ public class CachedValuesManagerImpl extends CachedValuesManager {
if (dataHolder instanceof UserDataHolderEx) {
UserDataHolderEx dh = (UserDataHolderEx)dataHolder;
value = dh.getUserData(key);
if (isOutdated(value)) {
value = null;
dh.putUserData(key, null);
while (isOutdated(value)) {
if (dh.replace(key, value, null)) {
value = null;
break;
}
value = dh.getUserData(key);
}
if (value == null) {
value = createCachedValue(provider, trackValue);