access to indices after disposal doesn't lead to NPE (IDEA-164170)

This commit is contained in:
Maxim.Mossienko
2016-11-18 17:50:23 +01:00
parent 271357d4ef
commit 44a8ce13bd
@@ -74,6 +74,7 @@ public class MapReduceIndex<Key, Value, Input> implements UpdatableIndex<Key,Val
private PersistentHashMap<Integer, Integer> myInputsSnapshotMapping;
@Nullable protected PersistentHashMap<Integer, Collection<Key>> myInputsIndex;
private PersistentHashMap<Integer, String> myIndexingTrace;
private volatile boolean myDisposed;
private final ReentrantReadWriteLock myLock = new ReentrantReadWriteLock();
@@ -329,6 +330,7 @@ public class MapReduceIndex<Key, Value, Input> implements UpdatableIndex<Key,Val
LOG.error(e);
}
finally {
myDisposed = true;
lock.unlock();
}
}
@@ -389,6 +391,9 @@ public class MapReduceIndex<Key, Value, Input> implements UpdatableIndex<Key,Val
final Lock lock = getReadLock();
try {
lock.lock();
if (myDisposed) {
return new ValueContainerImpl<>();
}
ValueContainerImpl.ourDebugIndexInfo.set(myIndexId);
return myStorage.read(key);
}