Program: 113486
Project: 113486
Buggy source:
private void establishConnection(InetSocketAddress server,RPCClientConnection con){
  if (con.canReconnect()) {
    if (Logging.isDebug()) {
      Logging.logMessage(Logging.LEVEL_DEBUG,Category.net,this,"String_Node_Str",server.toString());
    }
    ChannelIO channel;
    try {
      if (sslOptions == null) {
        channel=new ChannelIO(SocketChannel.open());
      }
 else {
        if (sslOptions.isFakeSSLMode()) {
          channel=new SSLHandshakeOnlyChannelIO(SocketChannel.open(),sslOptions,true);
        }
 else {
          channel=new SSLChannelIO(SocketChannel.open(),sslOptions,true);
        }
      }
      channel.configureBlocking(false);
      channel.socket().setTcpNoDelay(true);
      if (sendBufferSize != -1) {
        channel.socket().setSendBufferSize(sendBufferSize);
        if (channel.socket().getSendBufferSize() != sendBufferSize) {
          Logging.logMessage(Logging.LEVEL_WARN,Category.net,this,"String_Node_Str" + sendBufferSize + "String_Node_Str"+ channel.socket().getSendBufferSize());
        }
      }
      if (receiveBufferSize != -1) {
        channel.socket().setReceiveBufferSize(receiveBufferSize);
        if (channel.socket().getReceiveBufferSize() != receiveBufferSize) {
          Logging.logMessage(Logging.LEVEL_WARN,Category.net,this,"String_Node_Str" + receiveBufferSize + "String_Node_Str"+ channel.socket().getReceiveBufferSize());
        }
      }
 else {
        channel.socket().setReceiveBufferSize(256 * 1024);
      }
      channel.connect(server);
      con.setChannel(channel);
      toBeEstablished.add(con);
      selector.wakeup();
      if (Logging.isDebug()) {
        Logging.logMessage(Logging.LEVEL_DEBUG,Category.net,this,"String_Node_Str");
        Logging.logMessage(Logging.LEVEL_DEBUG,Category.net,this,"String_Node_Str",channel.socket().getSendBufferSize());
        Logging.logMessage(Logging.LEVEL_DEBUG,Category.net,this,"String_Node_Str",channel.socket().getReceiveBufferSize());
      }
    }
 catch (    Exception ex) {
      if (Logging.isDebug()) {
        Logging.logMessage(Logging.LEVEL_DEBUG,Category.net,this,"String_Node_Str",con.getEndpoint().toString());
      }
      con.connectFailed();
      for (      RPCClientRequest rq : con.getSendQueue()) {
        rq.getResponse().requestFailed("String_Node_Str" + con.getEndpoint() + "String_Node_Str"+ ex+ "String_Node_Str");
      }
      con.getSendQueue().clear();
    }
  }
 else {
    if (Logging.isDebug()) {
      Logging.logMessage(Logging.LEVEL_DEBUG,Category.net,this,"String_Node_Str",con.getEndpoint().toString());
    }
synchronized (con) {
      for (      RPCClientRequest rq : con.getSendQueue()) {
        rq.getResponse().requestFailed("String_Node_Str" + con.getEndpoint() + "String_Node_Str");
        rq.freeBuffers();
      }
      con.getSendQueue().clear();
    }
  }
}

Fixed version (ground truth):
private void establishConnection(InetSocketAddress server,RPCClientConnection con){
  if (con.canReconnect()) {
    if (Logging.isDebug()) {
      Logging.logMessage(Logging.LEVEL_DEBUG,Category.net,this,"String_Node_Str",server.toString());
    }
    ChannelIO channel;
    try {
      if (sslOptions == null) {
        channel=new ChannelIO(SocketChannel.open());
      }
 else {
        if (sslOptions.isFakeSSLMode()) {
          channel=new SSLHandshakeOnlyChannelIO(SocketChannel.open(),sslOptions,true);
        }
 else {
          channel=new SSLChannelIO(SocketChannel.open(),sslOptions,true);
        }
      }
      channel.configureBlocking(false);
      channel.socket().setTcpNoDelay(true);
      if (sendBufferSize != -1) {
        channel.socket().setSendBufferSize(sendBufferSize);
        if (channel.socket().getSendBufferSize() != sendBufferSize) {
          Logging.logMessage(Logging.LEVEL_WARN,Category.net,this,"String_Node_Str" + sendBufferSize + "String_Node_Str"+ channel.socket().getSendBufferSize());
        }
      }
      if (receiveBufferSize != -1) {
        channel.socket().setReceiveBufferSize(receiveBufferSize);
        if (channel.socket().getReceiveBufferSize() != receiveBufferSize) {
          Logging.logMessage(Logging.LEVEL_WARN,Category.net,this,"String_Node_Str" + receiveBufferSize + "String_Node_Str"+ channel.socket().getReceiveBufferSize());
        }
      }
 else {
        channel.socket().setReceiveBufferSize(256 * 1024);
      }
      channel.connect(server);
      con.setChannel(channel);
      toBeEstablished.add(con);
      selector.wakeup();
      if (Logging.isDebug()) {
        Logging.logMessage(Logging.LEVEL_DEBUG,Category.net,this,"String_Node_Str");
        Logging.logMessage(Logging.LEVEL_DEBUG,Category.net,this,"String_Node_Str",channel.socket().getSendBufferSize());
        Logging.logMessage(Logging.LEVEL_DEBUG,Category.net,this,"String_Node_Str",channel.socket().getReceiveBufferSize());
      }
    }
 catch (    Exception ex) {
      if (Logging.isDebug()) {
        Logging.logMessage(Logging.LEVEL_DEBUG,Category.net,this,"String_Node_Str",con.getEndpoint().toString());
      }
      con.connectFailed();
      for (      RPCClientRequest rq : con.getSendQueue()) {
        rq.getResponse().requestFailed("String_Node_Str" + con.getEndpoint() + "String_Node_Str"+ ex+ "String_Node_Str");
        rq.freeBuffers();
      }
      con.getSendQueue().clear();
    }
  }
 else {
    if (Logging.isDebug()) {
      Logging.logMessage(Logging.LEVEL_DEBUG,Category.net,this,"String_Node_Str",con.getEndpoint().toString());
    }
synchronized (con) {
      for (      RPCClientRequest rq : con.getSendQueue()) {
        rq.getResponse().requestFailed("String_Node_Str" + con.getEndpoint() + "String_Node_Str");
        rq.freeBuffers();
      }
      con.getSendQueue().clear();
    }
  }
}