From a0507f4f31ef7dfb30216132cfcde21bd637bef4 Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Mon, 14 Sep 2015 13:25:32 +0100 Subject: [PATCH] added connection listener check --- .../java/net/openhft/chronicle/map/TcpReplicator.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/openhft/chronicle/map/TcpReplicator.java b/src/main/java/net/openhft/chronicle/map/TcpReplicator.java index 3b03a270c..ba2d0622e 100644 --- a/src/main/java/net/openhft/chronicle/map/TcpReplicator.java +++ b/src/main/java/net/openhft/chronicle/map/TcpReplicator.java @@ -389,8 +389,8 @@ final class TcpReplicator extends AbstractChannelReplicator implements Clo private void quietClose(@NotNull final SelectionKey key, @NotNull final Exception e) { if (LOG.isDebugEnabled()) LOG.debug("", e); - - if (key.channel() != null && key.attachment() != null) + + if (key.channel() != null && key.attachment() != null && connectionListener != null) connectionListener.onDisconnect(((SocketChannel) key.channel()).socket().getInetAddress(), ((Attached) key.attachment()).remoteIdentifier); @@ -581,7 +581,7 @@ final class TcpReplicator extends AbstractChannelReplicator implements Clo attached.remoteIdentifier = remoteIdentifier; final SocketChannel channel = (SocketChannel) key.channel(); - if (channel != null && channel.socket() != null) { + if (channel != null && channel.socket() != null && connectionListener != null) { connectionListener.onConnect(channel.socket().getInetAddress(), attached.remoteIdentifier, attached.isServer); } @@ -1144,8 +1144,8 @@ final class TcpReplicator extends AbstractChannelReplicator implements Clo /** * writes all the entries that have changed, to the buffer which will later be written to * TCP/IP - * @param modificationIterator a record of which entries have modification * + * @param modificationIterator a record of which entries have modification */ void entriesToBuffer(@NotNull final Replica.ModificationIterator modificationIterator) throws InterruptedException { @@ -1803,7 +1803,7 @@ class StatelessServerConnector { writeException(writer, e); - writeSizeAndFlags(sizeLocation , true, writer.in()); + writeSizeAndFlags(sizeLocation, true, writer.in()); return null; }