Don't call MapEventListener.onPut() from within ChronicleMap.acquireUsing(key, null) invocation, key is absent in the map instance, i. e. the new value was obtained via valueFactory.create()

This commit is contained in:
leventov
2014-09-19 09:42:46 +04:00
parent 0f53ed3c5b
commit e3a16746a5
2 changed files with 6 additions and 2 deletions
@@ -593,13 +593,15 @@ class ReplicatedChronicleMap<K, V> extends VanillaChronicleMap<K, V>
return onKeyPresentOnAcquire(key, usingValue, offset, entry);
} else {
boolean usingValuePassed = usingValue != null;
usingValue = tryObtainUsingValueOnAcquire(keyBytes, key, usingValue, create);
if (usingValue != null) {
// see VanillaChronicleMap.Segment.acquire() for explanation
// why `usingValue` is `create`.
offset = putEntryOnAcquire(keyBytes, hash2, usingValue, create, timestamp);
incrementSize();
notifyPut(offset, true, key, usingValue, posFromOffset(offset));
if (usingValuePassed || !create)
notifyPut(offset, true, key, usingValue, posFromOffset(offset));
return usingValue;
} else {
return null;
@@ -722,6 +722,7 @@ class VanillaChronicleMap<K, V> extends AbstractMap<K, V>
if (offset >= 0) {
return onKeyPresentOnAcquire(key, usingValue, offset, entry);
} else {
boolean usingValuePassed = usingValue != null;
usingValue = tryObtainUsingValueOnAcquire(keyBytes, key, usingValue, create);
if (usingValue != null) {
// If `create` is false, this method was called from get() or getUsing()
@@ -730,7 +731,8 @@ class VanillaChronicleMap<K, V> extends AbstractMap<K, V>
// rather than "using" container to fill up, even if it implements Byteable.
offset = putEntry(keyBytes, usingValue, create);
incrementSize();
notifyPut(offset, true, key, usingValue, posFromOffset(offset));
if (usingValuePassed || !create)
notifyPut(offset, true, key, usingValue, posFromOffset(offset));
return usingValue;
} else {
return null;