Program: 132460
Project: 132460
Buggy source:
private void checkForTimers(){
  long now=System.currentTimeMillis();
  if (now >= lastCheck + TIMEOUT_GRANULARITY) {
synchronized (connections) {
      Iterator<ConnectionState> conIter=connections.values().iterator();
      while (conIter.hasNext()) {
        ConnectionState con=conIter.next();
        if (con.lastUsed < (TimeSync.getLocalSystemTime() - CONNECTION_REMOVE_TIMEOUT)) {
          Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + con.endpoint);
          try {
            conIter.remove();
            cancelRequests(con);
            con.channel.close();
          }
 catch (          Exception ex) {
          }
 finally {
            con.freeBuffers();
          }
        }
        for (int i=1; i < 3; i++) {
          Iterator<SpeedyRequest> iter=(i == 1) ? con.receiveQ.iterator() : con.sendQ.iterator();
          while (iter.hasNext()) {
            SpeedyRequest rq=iter.next();
            if ((rq.status != SpeedyRequest.RequestStatus.FAILED) && (rq.status != SpeedyRequest.RequestStatus.FINISHED) && (rq.timeout > 0)) {
              rq.waited+=TIMEOUT_GRANULARITY;
              if (rq.waited > rq.timeout) {
                try {
                  Logging.logMessage(Logging.LEVEL_ERROR,this,"String_Node_Str" + rq.waited + "String_Node_Str"+ rq.timeout+ "String_Node_Str"+ con.channel.keyFor(selector).interestOps()+ "String_Node_Str"+ con.receiveQ.size());
                }
 catch (                Exception e) {
                }
                rq.status=SpeedyRequest.RequestStatus.FAILED;
                assert(!rq.listenerNotified);
                rq.listener.receiveRequest(rq);
                rq.listenerNotified=true;
                rq.freeBuffer();
                iter.remove();
                try {
                  rq.con.channel.close();
                  con.freeBuffers();
                  conIter.remove();
                  cancelRequests(rq.con);
                }
 catch (                Exception ex2) {
                  Logging.logMessage(Logging.LEVEL_DEBUG,this,ex2);
                }
              }
            }
          }
        }
      }
    }
    lastCheck=now;
  }
}

Fixed version (ground truth):
private void checkForTimers(){
  long now=System.currentTimeMillis();
  if (now >= lastCheck + TIMEOUT_GRANULARITY) {
synchronized (connections) {
      Iterator<ConnectionState> conIter=connections.values().iterator();
      while (conIter.hasNext()) {
        ConnectionState con=conIter.next();
        if (con.lastUsed < (System.currentTimeMillis() - CONNECTION_REMOVE_TIMEOUT)) {
          Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + con.endpoint);
          try {
            conIter.remove();
            cancelRequests(con);
            con.channel.close();
          }
 catch (          Exception ex) {
          }
 finally {
            con.freeBuffers();
          }
        }
        for (int i=1; i < 3; i++) {
          Iterator<SpeedyRequest> iter=(i == 1) ? con.receiveQ.iterator() : con.sendQ.iterator();
          while (iter.hasNext()) {
            SpeedyRequest rq=iter.next();
            if ((rq.status != SpeedyRequest.RequestStatus.FAILED) && (rq.status != SpeedyRequest.RequestStatus.FINISHED) && (rq.timeout > 0)) {
              rq.waited+=TIMEOUT_GRANULARITY;
              if (rq.waited > rq.timeout) {
                try {
                  Logging.logMessage(Logging.LEVEL_ERROR,this,"String_Node_Str" + rq.waited + "String_Node_Str"+ rq.timeout+ "String_Node_Str"+ con.channel.keyFor(selector).interestOps()+ "String_Node_Str"+ con.receiveQ.size());
                }
 catch (                Exception e) {
                }
                rq.status=SpeedyRequest.RequestStatus.FAILED;
                assert(!rq.listenerNotified);
                rq.listener.receiveRequest(rq);
                rq.listenerNotified=true;
                rq.freeBuffer();
                iter.remove();
                try {
                  rq.con.channel.close();
                  con.freeBuffers();
                  conIter.remove();
                  cancelRequests(rq.con);
                }
 catch (                Exception ex2) {
                  Logging.logMessage(Logging.LEVEL_DEBUG,this,ex2);
                }
              }
            }
          }
        }
      }
    }
    lastCheck=now;
  }
}