Program: 149394
Project: 149394
Buggy source:
@Override public synchronized Collection<NodeProvisioner.PlannedNode> provision(Label label,int excessWorkload){
  List<JSONObject> activeInstances;
  try {
    activeInstances=ElasticBoxSlaveHandler.getActiveInstances(this);
  }
 catch (  IOException ex) {
    LOGGER.log(Level.SEVERE,"String_Node_Str",ex);
    return Collections.EMPTY_LIST;
  }
  if (activeInstances.size() >= maxInstances) {
    LOGGER.log(Level.WARNING,MessageFormat.format("String_Node_Str",label.getName(),getDisplayName()));
    return Collections.EMPTY_LIST;
  }
  List<ElasticBoxSlave> pendingSlaves=getPendingSlaves(label,activeInstances);
  if (!pendingSlaves.isEmpty()) {
    Map<ElasticBoxSlave,Integer> slaveToNumOfAvailableExecutorsMap=new HashMap<ElasticBoxSlave,Integer>(pendingSlaves.size());
    for (    ElasticBoxSlave slave : pendingSlaves) {
      slaveToNumOfAvailableExecutorsMap.put(slave,slave.getNumExecutors());
    }
    for (    Queue.BuildableItem buildableItem : Queue.getInstance().getBuildableItems()) {
      for (Iterator<ElasticBoxSlave> iter=slaveToNumOfAvailableExecutorsMap.keySet().iterator(); iter.hasNext() && !slaveToNumOfAvailableExecutorsMap.isEmpty(); ) {
        ElasticBoxSlave slave=iter.next();
        if (slave.canTake(buildableItem) == null) {
          int numOfAvailabelExecutors=slaveToNumOfAvailableExecutorsMap.get(slave);
          numOfAvailabelExecutors--;
          if (numOfAvailabelExecutors == 0) {
            iter.remove();
            ;
          }
          break;
        }
      }
    }
    ;
    for (    int numOfAvailableExecutors : slaveToNumOfAvailableExecutorsMap.values()) {
      excessWorkload-=numOfAvailableExecutors;
    }
  }
  if (excessWorkload <= 0) {
    LOGGER.log(Level.INFO,MessageFormat.format("String_Node_Str",label.getName(),getDisplayName()));
  }
  List<NodeProvisioner.PlannedNode> plannedNodes=new ArrayList<NodeProvisioner.PlannedNode>();
  while (excessWorkload > 0) {
    try {
      ElasticBoxSlave newSlave;
      if (isLabelForReusableSlave(label)) {
        String[] ids=label.getName().substring(ElasticBoxLabelFinder.REUSE_PREFIX.length()).split("String_Node_Str");
        String profileId=ids[0];
        String boxVersion=null;
        if (ids.length > 1) {
          boxVersion=ids[1];
        }
        newSlave=new ElasticBoxSlave(profileId,boxVersion,false,this);
      }
 else {
        SlaveConfiguration slaveConfig=findSlaveConfiguration(label,activeInstances);
        if (slaveConfig == null) {
          LOGGER.log(Level.WARNING,MessageFormat.format("String_Node_Str",label.getName()));
          break;
        }
        newSlave=new ElasticBoxSlave(slaveConfig,this);
      }
      final ElasticBoxSlave slave=newSlave;
      plannedNodes.add(new NodeProvisioner.PlannedNode(slave.getDisplayName(),new FutureWrapper<Node>(Computer.threadPoolForRemoting.submit(new Callable<Node>(){
        public Node call() throws Exception {
          slave.setInUse(true);
          Jenkins.getInstance().addNode(slave);
          IProgressMonitor monitor=ElasticBoxSlaveHandler.submit(slave);
          monitor.waitForDone(slave.getLaunchTimeout());
          if (slave.getComputer() != null && slave.getComputer().isOnline()) {
            return slave;
          }
 else {
            throw new Exception(MessageFormat.format("String_Node_Str",slave.getDisplayName()));
          }
        }
      }
)),1));
      excessWorkload-=slave.getNumExecutors();
    }
 catch (    Descriptor.FormException ex) {
      LOGGER.log(Level.SEVERE,ex.getMessage(),ex);
      break;
    }
catch (    IOException ex) {
      LOGGER.log(Level.SEVERE,ex.getMessage(),ex);
      break;
    }
  }
  return plannedNodes;
}

Fixed version (ground truth):
@Override public synchronized Collection<NodeProvisioner.PlannedNode> provision(Label label,int excessWorkload){
  List<JSONObject> activeInstances;
  try {
    activeInstances=ElasticBoxSlaveHandler.getActiveInstances(this);
  }
 catch (  IOException ex) {
    LOGGER.log(Level.SEVERE,"String_Node_Str",ex);
    return Collections.EMPTY_LIST;
  }
  if (activeInstances.size() >= maxInstances) {
    LOGGER.log(Level.WARNING,MessageFormat.format("String_Node_Str",label.getName(),getDisplayName()));
    return Collections.EMPTY_LIST;
  }
  List<ElasticBoxSlave> pendingSlaves=getPendingSlaves(label,activeInstances);
  if (!pendingSlaves.isEmpty()) {
    Map<ElasticBoxSlave,Integer> slaveToNumOfAvailableExecutorsMap=new HashMap<ElasticBoxSlave,Integer>(pendingSlaves.size());
    for (    ElasticBoxSlave slave : pendingSlaves) {
      slaveToNumOfAvailableExecutorsMap.put(slave,slave.getNumExecutors());
    }
    for (    Queue.BuildableItem buildableItem : Queue.getInstance().getBuildableItems()) {
      for (Iterator<ElasticBoxSlave> iter=slaveToNumOfAvailableExecutorsMap.keySet().iterator(); iter.hasNext() && !slaveToNumOfAvailableExecutorsMap.isEmpty(); ) {
        ElasticBoxSlave slave=iter.next();
        if (slave.canTake(buildableItem) == null) {
          int numOfAvailabelExecutors=slaveToNumOfAvailableExecutorsMap.get(slave);
          numOfAvailabelExecutors--;
          if (numOfAvailabelExecutors == 0) {
            iter.remove();
            ;
          }
          break;
        }
      }
    }
    ;
    for (    int numOfAvailableExecutors : slaveToNumOfAvailableExecutorsMap.values()) {
      excessWorkload-=numOfAvailableExecutors;
    }
  }
  if (excessWorkload <= 0) {
    LOGGER.log(Level.INFO,MessageFormat.format("String_Node_Str",label.getName(),getDisplayName()));
  }
  List<NodeProvisioner.PlannedNode> plannedNodes=new ArrayList<NodeProvisioner.PlannedNode>();
  while (excessWorkload > 0) {
    try {
      ElasticBoxSlave newSlave;
      if (isLabelForReusableSlave(label)) {
        String[] ids=label.getName().substring(ElasticBoxLabelFinder.REUSE_PREFIX.length()).split("String_Node_Str");
        String profileId=ids[0];
        String boxVersion=null;
        if (ids.length > 1) {
          boxVersion=ids[1];
        }
        newSlave=new ElasticBoxSlave(profileId,boxVersion,false,this);
      }
 else {
        SlaveConfiguration slaveConfig=findSlaveConfiguration(label,activeInstances);
        if (slaveConfig == null) {
          LOGGER.log(Level.WARNING,MessageFormat.format("String_Node_Str",label.getName()));
          break;
        }
        newSlave=new ElasticBoxSlave(slaveConfig,this);
      }
      final ElasticBoxSlave slave=newSlave;
      plannedNodes.add(new NodeProvisioner.PlannedNode(slave.getDisplayName(),new FutureWrapper<Node>(Computer.threadPoolForRemoting.submit(new Callable<Node>(){
        public Node call() throws Exception {
          Jenkins.getInstance().addNode(slave);
          IProgressMonitor monitor=ElasticBoxSlaveHandler.submit(slave);
          monitor.waitForDone(slave.getLaunchTimeout());
          if (slave.getComputer() != null && slave.getComputer().isOnline()) {
            return slave;
          }
 else {
            throw new Exception(MessageFormat.format("String_Node_Str",slave.getDisplayName()));
          }
        }
      }
)),1));
      excessWorkload-=slave.getNumExecutors();
    }
 catch (    Descriptor.FormException ex) {
      LOGGER.log(Level.SEVERE,ex.getMessage(),ex);
      break;
    }
catch (    IOException ex) {
      LOGGER.log(Level.SEVERE,ex.getMessage(),ex);
      break;
    }
  }
  return plannedNodes;
}