Program: 132461
Project: 132461
Buggy source:
/** 
 * Called to send a response.
 * @attention rq must have a connection attached!
 * @param rq the request to be sent
 * @throws java.lang.IllegalStateException if the send queue is full
 * @throws java.io.IOException passes all exceptions from the used IO primitives
 */
public void sendRequest(SpeedyRequest rq,InetSocketAddress server) throws IOException, IllegalStateException {
  if (rq.listener == null) {
    if (singleListener != null) {
      rq.listener=singleListener;
    }
 else {
      rq.listener=this.listeners.get(server);
      if (rq.listener == null)       throw new RuntimeException("String_Node_Str" + server);
    }
  }
  ConnectionState con=null;
synchronized (connections) {
    con=connections.get(server);
    if (con == null) {
      Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + server);
      ChannelIO channel;
      try {
        if (sslOptions == null) {
          channel=new ChannelIO(SocketChannel.open());
        }
 else {
          channel=new SSLChannelIO(SocketChannel.open(),sslOptions,true);
        }
      }
 catch (      IOException ex) {
        System.out.println("String_Node_Str");
        System.out.println(this.getStatus());
        System.out.println();
        throw ex;
      }
      channel.configureBlocking(false);
      channel.socket().setTcpNoDelay(true);
      channel.socket().setReceiveBufferSize(256 * 1024);
      channel.connect(server);
      con=new ConnectionState(channel);
      con.endpoint=server;
      newCons.add(con);
      connections.put(server,con);
      rq.registerConnection(con);
      rq.status=SpeedyRequest.RequestStatus.PENDING;
      con.sendQ.add(rq);
      Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str");
      selector.wakeup();
    }
 else {
      if (con.conRetries >= MultiSpeedy.MAX_RECONNECT) {
        if (con.canReconnect()) {
          con.conRetries=0;
          con.channel=null;
          Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + con.endpoint);
        }
 else {
          throw new IOException("String_Node_Str");
        }
      }
      if (con.channel == null) {
        Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + server);
        reconnect(con);
      }
      con.lastUsed=TimeSync.getLocalSystemTime();
      rq.registerConnection(con);
      rq.status=SpeedyRequest.RequestStatus.PENDING;
      con.sendQ.add(rq);
      SelectionKey key=con.channel.keyFor(selector);
      if (key != null) {
        if (key.isValid()) {
synchronized (key) {
            key.interestOps(key.interestOps() | SelectionKey.OP_WRITE);
          }
        }
 else         Logging.logMessage(Logging.LEVEL_WARN,this,"String_Node_Str" + server);
      }
 else {
        Logging.logMessage(Logging.LEVEL_WARN,this,"String_Node_Str" + server);
      }
      Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + server);
      selector.wakeup();
    }
  }
}

Fixed version (ground truth):
/** 
 * Called to send a response.
 * @attention rq must have a connection attached!
 * @param rq the request to be sent
 * @throws java.lang.IllegalStateException if the send queue is full
 * @throws java.io.IOException passes all exceptions from the used IO primitives
 */
public void sendRequest(SpeedyRequest rq,InetSocketAddress server) throws IOException, IllegalStateException {
  if (rq.listener == null) {
    if (singleListener != null) {
      rq.listener=singleListener;
    }
 else {
      rq.listener=this.listeners.get(server);
      if (rq.listener == null)       throw new RuntimeException("String_Node_Str" + server);
    }
  }
  ConnectionState con=null;
synchronized (connections) {
    con=connections.get(server);
    if (con == null) {
      Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + server);
      ChannelIO channel;
      try {
        if (sslOptions == null) {
          channel=new ChannelIO(SocketChannel.open());
        }
 else {
          channel=new SSLChannelIO(SocketChannel.open(),sslOptions,true);
        }
      }
 catch (      IOException ex) {
        System.out.println("String_Node_Str");
        System.out.println(this.getStatus());
        System.out.println();
        throw ex;
      }
      channel.configureBlocking(false);
      channel.socket().setTcpNoDelay(true);
      channel.socket().setReceiveBufferSize(256 * 1024);
      channel.connect(server);
      con=new ConnectionState(channel);
      con.endpoint=server;
      newCons.add(con);
      connections.put(server,con);
      rq.registerConnection(con);
      rq.status=SpeedyRequest.RequestStatus.PENDING;
      con.sendQ.add(rq);
      Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str");
      selector.wakeup();
    }
 else {
      if (con.conRetries >= MultiSpeedy.MAX_RECONNECT) {
        if (con.canReconnect()) {
          con.conRetries=0;
          con.channel=null;
          Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + con.endpoint);
        }
 else {
          throw new IOException("String_Node_Str");
        }
      }
      if (con.channel == null) {
        Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + server);
        reconnect(con);
      }
      con.lastUsed=System.currentTimeMillis();
      rq.registerConnection(con);
      rq.status=SpeedyRequest.RequestStatus.PENDING;
      con.sendQ.add(rq);
      SelectionKey key=con.channel.keyFor(selector);
      if (key != null) {
        if (key.isValid()) {
synchronized (key) {
            key.interestOps(key.interestOps() | SelectionKey.OP_WRITE);
          }
        }
 else         Logging.logMessage(Logging.LEVEL_WARN,this,"String_Node_Str" + server);
      }
 else {
        Logging.logMessage(Logging.LEVEL_WARN,this,"String_Node_Str" + server);
      }
      Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + server);
      selector.wakeup();
    }
  }
}