Fix a possible bug in ReplicatedMapAbsent.doInsert()

This commit is contained in:
leventov
2015-11-01 13:58:55 +03:00
parent 2411a5477b
commit c5e505525d
@@ -35,22 +35,26 @@ public abstract class ReplicatedMapAbsent<K, V> extends MapAbsent<K, V> {
@Override
public void doInsert(Data<V> value) {
q.putPrefix();
// TODO relax locks only after spec completion and analysis
s.innerUpdateLock.lock();
if (!q.entryPresent()) {
if (!ks.searchStatePresent()) {
putEntry(value);
e.updatedReplicationStateOnAbsentEntry();
ks.setSearchState(PRESENT);
q.initPresenceOfEntry(EntryPresence.PRESENT);
} else {
e.innerDefaultReplaceValue(value);
e.updatedReplicationStateOnPresentEntry();
s.deleted(s.deleted() - 1);
}
s.incrementModCount();
e.writeEntryPresent();
ru.updateChange();
e.updatedReplicationStateOnAbsentEntry();
e.checksumStrategy.computeAndStoreChecksum();
} else {
throw new IllegalStateException("Entry is absent in the map when doInsert() is called");
throw new IllegalStateException(
"Entry is present in the map when doInsert() is called");
}
}
}