From e14461249d54d5f4096dffca5cb5ca9e727f42cb Mon Sep 17 00:00:00 2001 From: Peter Lawrey Date: Wed, 10 Dec 2014 10:44:48 +0000 Subject: [PATCH] HCOLL-231 Close the connection when the attached is dropped. --- src/main/java/net/openhft/chronicle/map/TcpReplicator.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/openhft/chronicle/map/TcpReplicator.java b/src/main/java/net/openhft/chronicle/map/TcpReplicator.java index efec51608..004c63cb0 100644 --- a/src/main/java/net/openhft/chronicle/map/TcpReplicator.java +++ b/src/main/java/net/openhft/chronicle/map/TcpReplicator.java @@ -592,7 +592,11 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable final long approxTime) throws IOException { final SocketChannel socketChannel = (SocketChannel) key.channel(); final Attached attached = (Attached) key.attachment(); - if (attached == null) throw new NullPointerException("No attached"); + if (attached == null) { + LOG.info("Closing connection " + socketChannel + ", nothing attached"); + socketChannel.close(); + return; + } TcpSocketChannelEntryWriter entryWriter = attached.entryWriter; if (entryWriter == null) throw new NullPointerException("No entryWriter"); if (entryWriter.isWorkIncomplete()) {