@Override public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { super.channelDisconnected(ctx, e); smtpMetrics.getConnectionMetric().decrement(); }
@Override public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { try (Closeable closeable = IMAPMDCContext.from(ctx, attributes)) { InetSocketAddress address = (InetSocketAddress) ctx.getChannel().getRemoteAddress(); LOGGER.info("Connection closed for {}", address.getAddress().getHostAddress()); // remove the stored attribute for the channel to free up resources // See JAMES-1195 ImapSession imapSession = (ImapSession) attributes.remove(ctx.getChannel()); if (imapSession != null) { imapSession.logout(); } imapConnectionsMetric.decrement(); super.channelClosed(ctx, e); } }