Program: 132372
Project: 132372
Buggy source:
/** 
 * <p>Use this if you want to send requests to the slaves. The open-request-counter of the returned slaves will be incremented.</p> <p>Flow-control: If there are too many busy slaves, to get more or equal  syncN slaves, this operation blocks until enough slaves are available.</p>
 * @return a list of available slaves.
 * @throws NotEnoughAvailableSlavesException
 * @throws InterruptedException 
 */
public List<SlaveClient> getAvailableSlaves() throws NotEnoughAvailableSlavesException, InterruptedException {
  List<SlaveClient> result=new LinkedList<SlaveClient>();
synchronized (stateTable) {
    while (availableSlaves < syncN && !((slavesCount - deadSlaves) < syncN))     stateTable.wait();
    long time=TimeSync.getLocalSystemTime();
    if (!((slavesCount - deadSlaves) < syncN)) {
      for (      State slaveState : stateTable.values()) {
        if (!slaveState.dead) {
          if (slaveState.lastUpdate != 0L && time > (slaveState.lastUpdate + DELAY_TILL_DEAD)) {
            slaveState.dead=true;
            availableSlaves--;
          }
 else           if (slaveState.openRequests < MAX_OPEN_REQUESTS_PER_SLAVE) {
            slaveState.openRequests++;
            if (slaveState.openRequests == MAX_OPEN_REQUESTS_PER_SLAVE)             availableSlaves--;
            result.add(slaveState.client);
          }
        }
      }
    }
  }
  if (result.size() < syncN)   throw new NotEnoughAvailableSlavesException("String_Node_Str" + result.size() + "String_Node_Str"+ "String_Node_Str");
  return result;
}

Fixed version (ground truth):
/** 
 * <p>Use this if you want to send requests to the slaves. The open-request-counter of the returned slaves will be incremented.</p> <p>Flow-control: If there are too many busy slaves, to get more or equal  syncN slaves, this operation blocks until enough slaves are available.</p>
 * @return a list of available slaves.
 * @throws NotEnoughAvailableSlavesException
 * @throws InterruptedException 
 */
public List<SlaveClient> getAvailableSlaves() throws NotEnoughAvailableSlavesException, InterruptedException {
  List<SlaveClient> result=new LinkedList<SlaveClient>();
synchronized (stateTable) {
    while (availableSlaves < syncN && !((slavesCount - deadSlaves) < syncN))     stateTable.wait(WAIT_TILL_REFUSE);
    long time=TimeSync.getLocalSystemTime();
    if (!((slavesCount - deadSlaves) < syncN)) {
      for (      State slaveState : stateTable.values()) {
        if (!slaveState.dead) {
          if (slaveState.lastUpdate != 0L && time > (slaveState.lastUpdate + DELAY_TILL_DEAD)) {
            slaveState.dead=true;
            availableSlaves--;
          }
 else           if (slaveState.openRequests < MAX_OPEN_REQUESTS_PER_SLAVE) {
            slaveState.openRequests++;
            if (slaveState.openRequests == MAX_OPEN_REQUESTS_PER_SLAVE)             availableSlaves--;
            result.add(slaveState.client);
          }
        }
      }
    }
    if (result.size() < syncN) {
      for (      SlaveClient c : result) {
        State s=stateTable.get(c.getDefaultServerAddress().getAddress());
        if (s.openRequests == MAX_OPEN_REQUESTS_PER_SLAVE)         availableSlaves++;
        s.openRequests--;
      }
      throw new NotEnoughAvailableSlavesException("String_Node_Str" + result.size() + "String_Node_Str"+ "String_Node_Str");
    }
  }
  return result;
}