@Override
  public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
    super.handlerRemoved(ctx);

    if (currentMessage != null) {
      currentMessage.release();
      currentMessage = null;
    }
  }
  @Override
  public void channelInactive(ChannelHandlerContext ctx) throws Exception {
    super.channelInactive(ctx);

    if (currentMessage != null) {
      currentMessage.release();
      currentMessage = null;
    }
  }
 /* (non-Javadoc)
  * @see io.netty.channel.ChannelStateHandlerAdapter#channelInactive(io.netty.channel.ChannelHandlerContext)
  */
 @Override
 public void channelInactive(ChannelHandlerContext ctx) throws Exception {
   super.channelInactive(ctx);
   rpcClient.handleClosure();
   notifyClosed();
 }