Program: 113485
Project: 113485
Buggy source:
private void checkForTimers(){
  long now=System.currentTimeMillis();
  if (now >= lastCheck + TIMEOUT_GRANULARITY) {
synchronized (connections) {
      Iterator<RPCClientConnection> conIter=connections.values().iterator();
      while (conIter.hasNext()) {
        final RPCClientConnection con=conIter.next();
        if (con.getLastUsed() < (now - connectionTimeout)) {
          if (Logging.isDebug()) {
            Logging.logMessage(Logging.LEVEL_DEBUG,Category.net,this,"String_Node_Str");
          }
          try {
            conIter.remove();
            closeConnection(con.getChannel().keyFor(selector),null);
          }
 catch (          Exception ex) {
          }
        }
 else {
          List<RPCClientRequest> cancelRq=new LinkedList<RPCClientRequest>();
synchronized (con) {
            Iterator<RPCClientRequest> iter=con.getRequests().values().iterator();
            while (iter.hasNext()) {
              final RPCClientRequest rq=iter.next();
              if (rq.getTimeQueued() + requestTimeout < now) {
                cancelRq.add(rq);
                iter.remove();
              }
            }
            iter=con.getSendQueue().iterator();
            while (iter.hasNext()) {
              final RPCClientRequest rq=iter.next();
              if (rq.getTimeQueued() + requestTimeout < now) {
                cancelRq.add(rq);
                iter.remove();
              }
 else {
                break;
              }
            }
          }
          for (          RPCClientRequest rq : cancelRq) {
            rq.getResponse().requestFailed("String_Node_Str");
          }
        }
      }
      lastCheck=now;
    }
  }
}

Fixed version (ground truth):
private void checkForTimers(){
  long now=System.currentTimeMillis();
  if (now >= lastCheck + TIMEOUT_GRANULARITY) {
synchronized (connections) {
      Iterator<RPCClientConnection> conIter=connections.values().iterator();
      while (conIter.hasNext()) {
        final RPCClientConnection con=conIter.next();
        if (con.getLastUsed() < (now - connectionTimeout)) {
          if (Logging.isDebug()) {
            Logging.logMessage(Logging.LEVEL_DEBUG,Category.net,this,"String_Node_Str");
          }
          try {
            conIter.remove();
            closeConnection(con.getChannel().keyFor(selector),null);
          }
 catch (          Exception ex) {
          }
        }
 else {
          List<RPCClientRequest> cancelRq=new LinkedList<RPCClientRequest>();
synchronized (con) {
            Iterator<RPCClientRequest> iter=con.getRequests().values().iterator();
            while (iter.hasNext()) {
              final RPCClientRequest rq=iter.next();
              if (rq.getTimeQueued() + requestTimeout < now) {
                cancelRq.add(rq);
                iter.remove();
              }
            }
            iter=con.getSendQueue().iterator();
            while (iter.hasNext()) {
              final RPCClientRequest rq=iter.next();
              if (rq.getTimeQueued() + requestTimeout < now) {
                cancelRq.add(rq);
                iter.remove();
              }
 else {
                break;
              }
            }
          }
          for (          RPCClientRequest rq : cancelRq) {
            rq.getResponse().requestFailed("String_Node_Str");
            rq.freeBuffers();
          }
        }
      }
      lastCheck=now;
    }
  }
}