Program: 15173
Project: 15173
Buggy source:
@Override public void allocate(Allocation allocInfo) throws Exception {
  RunInstancesType request=allocInfo.getRequest();
  String clusterName=request.getAvailabilityZone();
  String vmTypeName=request.getInstanceType();
  final int minAmount=request.getMinCount();
  final int maxAmount=request.getMaxCount();
  Context ctx=Contexts.lookup();
  if (false) {
    throw new NotEnoughResourcesAvailable("String_Node_Str" + clusterName);
  }
 else {
    String zoneName=(clusterName != null) ? clusterName : "String_Node_Str";
    String action=PolicySpec.requestToAction(request);
    User requestUser=ctx.getUser();
    List<Cluster> authorizedClusters=this.doPrivilegedLookup(zoneName,vmTypeName,action,requestUser);
    int remaining=maxAmount;
    int available=0;
    LOG.info("String_Node_Str" + Iterables.transform(authorizedClusters,new Function<Cluster,String>(){
      @Override public String apply(      Cluster arg0){
        return arg0.getName();
      }
    }
));
    if ((available=checkAvailability(vmTypeName,authorizedClusters)) < minAmount) {
      throw new NotEnoughResourcesAvailable("String_Node_Str" + available + "String_Node_Str"+ zoneName+ "String_Node_Str"+ minAmount+ "String_Node_Str");
    }
 else {
      for (      ClusterNodeState state : Lists.transform(authorizedClusters,new Function<Cluster,ClusterNodeState>(){
        @Override public ClusterNodeState apply(        Cluster arg0){
          return arg0.getNodeState();
        }
      }
)) {
        try {
          int tryAmount=(remaining > state.getAvailability(vmTypeName).getAvailable()) ? state.getAvailability(vmTypeName).getAvailable() : remaining;
          ResourceToken token=allocInfo.requestResourceToken(state,vmTypeName,tryAmount,maxAmount);
          remaining-=token.getAmount();
        }
 catch (        Throwable t) {
          if (((available=checkAvailability(vmTypeName,authorizedClusters)) < remaining) || remaining > 0) {
            allocInfo.releaseAllocationTokens();
            throw new NotEnoughResourcesAvailable("String_Node_Str" + available + "String_Node_Str"+ zoneName+ "String_Node_Str"+ minAmount+ "String_Node_Str");
          }
 else {
            LOG.error(t,t);
            throw new NotEnoughResourcesAvailable("String_Node_Str" + available + "String_Node_Str"+ zoneName+ "String_Node_Str"+ minAmount+ "String_Node_Str");
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override public void allocate(Allocation allocInfo) throws Exception {
  RunInstancesType request=allocInfo.getRequest();
  String clusterName=request.getAvailabilityZone();
  String vmTypeName=request.getInstanceType();
  final int minAmount=request.getMinCount();
  final int maxAmount=request.getMaxCount();
  Context ctx=Contexts.lookup();
  if (false) {
    throw new NotEnoughResourcesAvailable("String_Node_Str" + clusterName);
  }
 else {
    String zoneName=(clusterName != null) ? clusterName : "String_Node_Str";
    String action=PolicySpec.requestToAction(request);
    User requestUser=ctx.getUser();
    List<Cluster> authorizedClusters=this.doPrivilegedLookup(zoneName,vmTypeName,action,requestUser);
    int remaining=maxAmount;
    int available=0;
    LOG.info("String_Node_Str" + Iterables.transform(authorizedClusters,new Function<Cluster,String>(){
      @Override public String apply(      Cluster arg0){
        return arg0.getName();
      }
    }
));
    if ((available=checkAvailability(vmTypeName,authorizedClusters)) < minAmount) {
      throw new NotEnoughResourcesAvailable("String_Node_Str" + available + "String_Node_Str"+ zoneName+ "String_Node_Str"+ minAmount+ "String_Node_Str");
    }
 else {
      for (      Cluster cluster : authorizedClusters) {
        ClusterNodeState state=cluster.getNodeState();
        try {
          if (allocInfo.getBootSet().getMachine() instanceof BlockStorageImageInfo) {
            try {
              ServiceConfiguration sc=Partitions.lookupService(Storage.class,cluster.getConfiguration().getPartition());
            }
 catch (            Exception ex) {
              throw new NotEnoughResourcesAvailable("String_Node_Str" + ex.getMessage(),ex);
            }
          }
          int tryAmount=(remaining > state.getAvailability(vmTypeName).getAvailable()) ? state.getAvailability(vmTypeName).getAvailable() : remaining;
          ResourceToken token=allocInfo.requestResourceToken(state,vmTypeName,tryAmount,maxAmount);
          remaining-=token.getAmount();
        }
 catch (        Throwable t) {
          if (((available=checkAvailability(vmTypeName,authorizedClusters)) < remaining) || remaining > 0) {
            allocInfo.releaseAllocationTokens();
            throw new NotEnoughResourcesAvailable("String_Node_Str" + available + "String_Node_Str"+ zoneName+ "String_Node_Str"+ minAmount+ "String_Node_Str");
          }
 else {
            LOG.error(t,t);
            throw new NotEnoughResourcesAvailable("String_Node_Str" + available + "String_Node_Str"+ zoneName+ "String_Node_Str"+ minAmount+ "String_Node_Str");
          }
        }
      }
    }
  }
}