/** * Closes the message buffer. */ public void close() { synchronized (this) { if (closed) { return; } closed = true; } bytesIn.freeze(); bytesOut.freeze(); messagesIn.freeze(); messagesOut.freeze(); loop.removeStream(this); if (key != null) { try { key.cancel(); key.channel().close(); } catch (IOException e) { log.warn("Unable to close stream", e); } } }