Exemple #1
0
  @Override
  public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {

    // Make sure the handshake future is notified when a connection has
    // been closed during handshake.
    synchronized (handshakeLock) {
      if (handshaking) {
        handshakeFuture.setFailure(new ClosedChannelException());
      }
    }

    try {
      super.channelDisconnected(ctx, e);
    } finally {
      unwrap(ctx, e.getChannel(), ChannelBuffers.EMPTY_BUFFER, 0, 0);
      engine.closeOutbound();
      if (!sentCloseNotify.get() && handshaken) {
        try {
          engine.closeInbound();
        } catch (SSLException ex) {
          logger.debug("Failed to clean up SSLEngine.", ex);
        }
      }
    }
  }