Program: 14501
Project: 14501
Buggy source:
public synchronized List<ResourceToken> requestResourceAllocation(Allocation allocInfo,int minAmount,int maxAmount) throws NotEnoughResourcesException {
  VmTypeAvailability vmTypeStatus=this.typeMap.get(allocInfo.getVmType().getName());
  Integer available=vmTypeStatus.getAvailable();
  NavigableSet<VmTypeAvailability> sorted=this.sorted();
  LOG.debug(LogUtil.header("String_Node_Str"));
  LOG.debug(sorted);
  Integer quantity=minAmount;
  if (vmTypeStatus.getAvailable() < minAmount) {
    throw new NotEnoughResourcesException("String_Node_Str" + available + "String_Node_Str"+ minAmount+ "String_Node_Str");
  }
 else {
    quantity=(maxAmount < available ? maxAmount : available);
  }
  Set<VmTypeAvailability> tailSet=sorted.tailSet(vmTypeStatus);
  Set<VmTypeAvailability> headSet=sorted.headSet(vmTypeStatus);
  LOG.debug(LogUtil.header("String_Node_Str"));
  LOG.debug(LogUtil.subheader("String_Node_Str" + tailSet));
  LOG.debug(LogUtil.subheader("String_Node_Str" + headSet));
  for (  VmTypeAvailability v : tailSet)   v.decrement(quantity);
  for (  VmTypeAvailability v : headSet)   v.setAvailable(vmTypeStatus.getAvailable());
  LOG.debug(LogUtil.header("String_Node_Str"));
  LOG.debug(sorted);
  int seqNumber=this.virtualTimer++;
  List<ResourceToken> tokenList=Lists.newArrayList();
  for (int i=0; i < quantity; i++) {
    ResourceToken token=new ResourceToken(allocInfo,seqNumber,i);
    LOG.debug(EventType.TOKEN_RESERVED.name() + "String_Node_Str" + token.toString());
    this.pendingTokens.add(token);
    tokenList.add(token);
  }
  return tokenList;
}

Fixed version (ground truth):
public synchronized List<ResourceToken> requestResourceAllocation(Allocation allocInfo,int minAmount,int maxAmount) throws NotEnoughResourcesException {
  VmTypeAvailability vmTypeStatus=this.typeMap.get(allocInfo.getVmType().getName());
  Integer available=vmTypeStatus.getAvailable();
  NavigableSet<VmTypeAvailability> sorted=this.sorted();
  LOG.debug(LogUtil.header("String_Node_Str"));
  LOG.debug(sorted);
  Integer quantity=minAmount;
  if (vmTypeStatus.getAvailable() < minAmount) {
    throw new NotEnoughResourcesException("String_Node_Str" + available + "String_Node_Str"+ minAmount+ "String_Node_Str");
  }
 else {
    quantity=(maxAmount < available ? maxAmount : available);
  }
  Set<VmTypeAvailability> tailSet=sorted.tailSet(vmTypeStatus);
  Set<VmTypeAvailability> headSet=sorted.headSet(vmTypeStatus);
  LOG.debug(LogUtil.header("String_Node_Str"));
  LOG.debug(LogUtil.subheader("String_Node_Str" + tailSet));
  LOG.debug(LogUtil.subheader("String_Node_Str" + headSet));
  for (  VmTypeAvailability v : tailSet)   v.decrement(quantity);
  for (  VmTypeAvailability v : headSet)   v.setAvailable(vmTypeStatus.getAvailable());
  LOG.debug(LogUtil.header("String_Node_Str"));
  LOG.debug(sorted);
  int seqNumber=this.virtualTimer++;
  List<ResourceToken> tokenList=Lists.newArrayList();
  for (int i=0; i < quantity; i++) {
    try {
      ResourceToken token=new ResourceToken(allocInfo,seqNumber,i);
      LOG.debug(EventType.TOKEN_RESERVED.name() + "String_Node_Str" + token.toString());
      this.pendingTokens.add(token);
      tokenList.add(token);
    }
 catch (    Exception ex) {
      LOG.error(ex);
      Logs.extreme().error(ex,ex);
      for (      ResourceToken token : tokenList) {
        this.pendingTokens.remove(token);
      }
    }
  }
  return tokenList;
}