Program: 96502
Project: 96502
Buggy source:
@Override public void filterClose(final NextFilter nextFilter,final IoSession session) throws Exception {
  if (timedOut.get() == true) {
    nextFilter.filterClose(session);
    return;
  }
  if (!session.isConnected()) {
    if (logger != null && logger.isTraceEnabled()) {
      logger.trace(format("String_Node_Str"));
    }
    nextFilter.filterClose(session);
    return;
  }
  if (sentCloseFrame.get() == false) {
    WsnSession wsnSession=SESSION_KEY.get(session);
    Throwable cause=wsnSession == null ? null : wsnSession.getCloseException();
    WsCloseMessage closeMessage;
    if (cause != null && cause instanceof ProtocolDecoderException) {
      closeMessage=WsCloseMessage.PROTOCOL_ERROR;
    }
 else {
      closeMessage=WsCloseMessage.NORMAL_CLOSE;
    }
    WriteFutureEx writeFuture=new DefaultWriteFutureEx(session);
    WriteRequestEx writeRequest=new DefaultWriteRequestEx(closeMessage,writeFuture);
    if (receivedCloseFrame.get() == true) {
      writeFuture.addListener(new IoFutureListener<WriteFuture>(){
        @Override public void operationComplete(        WriteFuture future){
          if (future.isWritten()) {
            if (closeFuture != null && closeFuture.isDone() == false) {
              closeFuture.cancel(true);
            }
            nextFilter.filterClose(session);
          }
 else {
            if (logger != null && logger.isTraceEnabled()) {
              logger.trace(format("String_Node_Str",future.getException()));
            }
            nextFilter.filterClose(session);
          }
        }
      }
);
    }
    super.filterWrite(nextFilter,session,writeRequest);
  }
 else {
    if (receivedCloseFrame.get() == true) {
      if (closeFuture != null && closeFuture.isDone() == false) {
        closeFuture.cancel(true);
      }
      nextFilter.filterClose(session);
    }
  }
}

Fixed version (ground truth):
@Override public void filterClose(final NextFilter nextFilter,final IoSession session) throws Exception {
  if (timedOut.get() == true) {
    nextFilter.filterClose(session);
    return;
  }
  if (!session.isConnected()) {
    if (logger != null && logger.isTraceEnabled()) {
      logger.trace(format("String_Node_Str"));
    }
    nextFilter.filterClose(session);
    return;
  }
  if (sentCloseFrame.get() == false) {
    WsnSession wsnSession=SESSION_KEY.get(session);
    Throwable cause=wsnSession == null ? null : wsnSession.getCloseException();
    WsCloseMessage closeMessage;
    if (cause != null) {
      if (cause instanceof WSMessageTooLongException) {
        closeMessage=WsCloseMessage.MESSAGE_TOO_LONG_ERROR;
      }
 else       if (cause instanceof ProtocolDecoderException) {
        closeMessage=WsCloseMessage.PROTOCOL_ERROR;
      }
 else {
        closeMessage=WsCloseMessage.NORMAL_CLOSE;
      }
    }
 else {
      closeMessage=WsCloseMessage.NORMAL_CLOSE;
    }
    WriteFutureEx writeFuture=new DefaultWriteFutureEx(session);
    WriteRequestEx writeRequest=new DefaultWriteRequestEx(closeMessage,writeFuture);
    if (receivedCloseFrame.get() == true) {
      writeFuture.addListener(new IoFutureListener<WriteFuture>(){
        @Override public void operationComplete(        WriteFuture future){
          if (future.isWritten()) {
            if (closeFuture != null && closeFuture.isDone() == false) {
              closeFuture.cancel(true);
            }
            nextFilter.filterClose(session);
          }
 else {
            if (logger != null && logger.isTraceEnabled()) {
              logger.trace(format("String_Node_Str",future.getException()));
            }
            nextFilter.filterClose(session);
          }
        }
      }
);
    }
    super.filterWrite(nextFilter,session,writeRequest);
  }
 else {
    if (receivedCloseFrame.get() == true) {
      if (closeFuture != null && closeFuture.isDone() == false) {
        closeFuture.cancel(true);
      }
      nextFilter.filterClose(session);
    }
  }
}