Program: 113766
Project: 113766
Buggy source:
public void run(){
  notifyStarted();
  lastCheck=System.currentTimeMillis();
  Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str");
  while (!quit) {
    int numKeys=0;
    try {
      numKeys=selector.select(TIMEOUT_GRANULARITY);
    }
 catch (    CancelledKeyException ex) {
    }
catch (    IOException ex) {
      Logging.logMessage(Logging.LEVEL_WARN,this,"String_Node_Str" + ex);
      continue;
    }
    if (!toBeEstablished.isEmpty()) {
      while (true) {
        ServerConnection con=toBeEstablished.poll();
        if (con == null)         break;
        try {
          con.getChannel().register(selector,SelectionKey.OP_CONNECT | SelectionKey.OP_WRITE | SelectionKey.OP_READ,con);
        }
 catch (        ClosedChannelException ex) {
          closeConnection(con.getChannel().keyFor(selector),ex);
        }
      }
      toBeEstablished.clear();
    }
    if (numKeys > 0) {
      Set<SelectionKey> keys=selector.selectedKeys();
      Iterator<SelectionKey> iter=keys.iterator();
      while (iter.hasNext()) {
        try {
          SelectionKey key=iter.next();
          iter.remove();
          if (key.isConnectable()) {
            connectConnection(key);
          }
          if (key.isReadable()) {
            readConnection(key);
          }
          if (key.isWritable()) {
            writeConnection(key);
          }
        }
 catch (        CancelledKeyException ex) {
          continue;
        }
      }
    }
    checkForTimers();
  }
  Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str");
  notifyStopped();
}

Fixed version (ground truth):
public void run(){
  notifyStarted();
  lastCheck=System.currentTimeMillis();
  Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str");
  while (!quit) {
    int numKeys=0;
    try {
      numKeys=selector.select(TIMEOUT_GRANULARITY);
    }
 catch (    CancelledKeyException ex) {
    }
catch (    IOException ex) {
      Logging.logMessage(Logging.LEVEL_WARN,this,"String_Node_Str" + ex);
      continue;
    }
    if (!toBeEstablished.isEmpty()) {
      while (true) {
        ServerConnection con=toBeEstablished.poll();
        if (con == null)         break;
        try {
          con.getChannel().register(selector,SelectionKey.OP_CONNECT | SelectionKey.OP_WRITE | SelectionKey.OP_READ,con);
        }
 catch (        ClosedChannelException ex) {
          closeConnection(con.getChannel().keyFor(selector),ex);
        }
      }
      toBeEstablished.clear();
    }
    if (numKeys > 0) {
      Set<SelectionKey> keys=selector.selectedKeys();
      Iterator<SelectionKey> iter=keys.iterator();
      while (iter.hasNext()) {
        try {
          SelectionKey key=iter.next();
          iter.remove();
          if (key.isConnectable()) {
            connectConnection(key);
          }
          if (key.isReadable()) {
            readConnection(key);
          }
          if (key.isWritable()) {
            writeConnection(key);
          }
        }
 catch (        CancelledKeyException ex) {
          continue;
        }
      }
    }
    checkForTimers();
  }
synchronized (connections) {
    for (    ServerConnection con : connections.values()) {
      for (      ONCRPCRequest rq : con.getSendQueue()) {
        rq.getListener().requestFailed(rq,new IOException("String_Node_Str"));
      }
      for (      ONCRPCRequest rq : con.getRequests().values()) {
        rq.getListener().requestFailed(rq,new IOException("String_Node_Str"));
      }
    }
  }
  Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str");
  notifyStopped();
}