mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
allow event listener to be NULL
This commit is contained in:
@@ -31,6 +31,7 @@ import net.openhft.lang.io.NativeBytes;
|
||||
import net.openhft.lang.model.Byteable;
|
||||
import net.openhft.lang.threadlocal.ThreadLocalCopies;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -1387,7 +1388,7 @@ final class ReplicatedChronicleMap<K, KI, MKI extends MetaBytesInterop<K, KI>,
|
||||
private final ATSDirectBitSet modIterSet;
|
||||
private final MapEventListener<K, V, ChronicleMap<K, V>> nextListener;
|
||||
|
||||
public ModificationDelegator(@NotNull final MapEventListener<K, V, ChronicleMap<K, V>> nextListener,
|
||||
public ModificationDelegator(@Nullable final MapEventListener<K, V, ChronicleMap<K, V>> nextListener,
|
||||
final Bytes bytes) {
|
||||
this.nextListener = nextListener;
|
||||
modIterSet = new ATSDirectBitSet(bytes);
|
||||
@@ -1430,11 +1431,12 @@ final class ReplicatedChronicleMap<K, KI, MKI extends MetaBytesInterop<K, KI>,
|
||||
|
||||
assert ReplicatedChronicleMap.this == map :
|
||||
"ModificationIterator.onPut() is called from outside of the parent map";
|
||||
try {
|
||||
nextListener.onPut(map, entry, metaDataBytes, added, key, replacedValue, value, pos, segment);
|
||||
} catch (Exception e) {
|
||||
LOG.error("", e);
|
||||
}
|
||||
if (nextListener != null)
|
||||
try {
|
||||
nextListener.onPut(map, entry, metaDataBytes, added, key, replacedValue, value, pos, segment);
|
||||
} catch (Exception e) {
|
||||
LOG.error("", e);
|
||||
}
|
||||
|
||||
dirty(map, pos, segment);
|
||||
}
|
||||
@@ -1459,7 +1461,9 @@ final class ReplicatedChronicleMap<K, KI, MKI extends MetaBytesInterop<K, KI>,
|
||||
K key, V value, long pos, SharedSegment segment) {
|
||||
assert ReplicatedChronicleMap.this == map :
|
||||
"ModificationIterator.onRemove() is called from outside of the parent map";
|
||||
try {
|
||||
|
||||
if (nextListener != null)
|
||||
try {
|
||||
nextListener.onRemove(map, entry, metaDataBytes, key, value, pos, segment);
|
||||
} catch (Exception e) {
|
||||
LOG.error("", e);
|
||||
@@ -1491,7 +1495,8 @@ final class ReplicatedChronicleMap<K, KI, MKI extends MetaBytesInterop<K, KI>,
|
||||
@Override
|
||||
public void onGetFound(ChronicleMap<K, V> map, Bytes entry, int metaDataBytes,
|
||||
K key, V value) {
|
||||
nextListener.onGetFound(map, entry, metaDataBytes, key, value);
|
||||
if (nextListener != null)
|
||||
nextListener.onGetFound(map, entry, metaDataBytes, key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user