allow event listener to be NULL

This commit is contained in:
Rob Austin
2014-11-24 10:10:34 +00:00
parent 12ceba9739
commit f7f886938b
@@ -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);
}
/**