mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user