@Override
  public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
    InetSocketAddress address = (InetSocketAddress) ctx.getChannel().getRemoteAddress();
    getLogger(ctx.getChannel())
        .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();

    super.channelClosed(ctx, e);
  }
 @Override
 public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent evt) throws Exception {
   // Clear the map for this context
   try {
     Logs.extreme()
         .debug(
             "Removing data map on channel closed event for channel: " + ctx.getChannel().getId());
     dataMap.remove(ctx.getChannel());
   } catch (final Throwable f) {
     // Nothing to lookup.
   } finally {
     super.channelClosed(ctx, evt);
   }
 }
 @Override
 public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
   LOG.info(
       "Connection to {} has been closed, channel = {}", client.getRemoteAddr(), e.getChannel());
   super.channelClosed(ctx, e);
 }
 @Override
 public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
   closeFuture.setResult(FutureResult.createVoid());
   super.channelClosed(ctx, e);
 }