Program: 15172
Project: 15172
Buggy source:
private ClusterAllocator(ResourceToken vmToken,Allocation allocInfo){
  this.allocInfo=allocInfo;
  if (vmToken != null) {
    try {
      this.cluster=Clusters.getInstance().lookup(vmToken.getCluster());
      this.sc=Partitions.lookupService(Storage.class,this.cluster.getPartition());
      this.messages=new StatefulMessageSet<State>(this.cluster,State.values());
      if (this.allocInfo.getBootSet().getMachine() instanceof BlockStorageImageInfo) {
        VirtualBootRecord root=allocInfo.getVmTypeInfo().lookupRoot();
        if (root.isBlockStorage()) {
          for (int i=0; i < vmToken.getAmount(); i++) {
            BlockStorageImageInfo imgInfo=((BlockStorageImageInfo)this.allocInfo.getBootSet().getMachine());
            int sizeGb=(int)Math.ceil(imgInfo.getImageSizeBytes() / (1024l * 1024l * 1024l));
            LOG.debug("String_Node_Str" + imgInfo + "String_Node_Str"+ root);
            Volume vol=Volumes.createStorageVolume(this.sc,this.allocInfo.getOwnerFullName(),imgInfo.getSnapshotId(),sizeGb,allocInfo.getRequest());
            if (imgInfo.getDeleteOnTerminate()) {
              this.allocInfo.getTransientVolumes().add(vol);
            }
 else {
              this.allocInfo.getPersistentVolumes().add(vol);
            }
          }
        }
      }
      for (      NetworkToken networkToken : vmToken.getNetworkTokens())       this.setupNetworkMessages(networkToken);
      this.setupVmMessages(vmToken);
    }
 catch (    Throwable e) {
      LOG.debug(e,e);
      try {
        Clusters.getInstance().lookup(vmToken.getCluster()).getNodeState().releaseToken(vmToken);
      }
 catch (      Throwable e1) {
        LOG.debug(e1);
        LOG.trace(e1,e1);
      }
      for (      String addr : vmToken.getAddresses()) {
        try {
          Addresses.release(Addresses.getInstance().lookup(addr));
        }
 catch (        Throwable e1) {
          LOG.debug(e1);
          LOG.trace(e1,e1);
        }
      }
      try {
        if (vmToken.getPrimaryNetwork() != null) {
          Network net=Networks.getInstance().lookup(vmToken.getPrimaryNetwork().getName());
          for (          Integer i : vmToken.getPrimaryNetwork().getIndexes()) {
            net.returnNetworkIndex(i);
          }
        }
      }
 catch (      Throwable e1) {
        LOG.debug(e1);
        LOG.trace(e1,e1);
      }
      for (      String vmId : vmToken.getInstanceIds()) {
        try {
          VmInstance vm=VmInstances.getInstance().lookup(vmId);
          vm.setState(VmState.TERMINATED,Reason.FAILED,e.getMessage());
          VmInstances.getInstance().disable(vmId);
        }
 catch (        Exception e1) {
          LOG.debug(e1,e1);
        }
      }
    }
  }
}

Fixed version (ground truth):
private ClusterAllocator(ResourceToken vmToken,Allocation allocInfo){
  this.allocInfo=allocInfo;
  if (vmToken != null) {
    try {
      this.cluster=Clusters.getInstance().lookup(vmToken.getCluster());
      this.messages=new StatefulMessageSet<State>(this.cluster,State.values());
      if (this.allocInfo.getBootSet().getMachine() instanceof BlockStorageImageInfo) {
        ServiceConfiguration sc=Partitions.lookupService(Storage.class,this.cluster.getPartition());
        VirtualBootRecord root=allocInfo.getVmTypeInfo().lookupRoot();
        if (root.isBlockStorage()) {
          for (int i=0; i < vmToken.getAmount(); i++) {
            BlockStorageImageInfo imgInfo=((BlockStorageImageInfo)this.allocInfo.getBootSet().getMachine());
            int sizeGb=(int)Math.ceil(imgInfo.getImageSizeBytes() / (1024l * 1024l * 1024l));
            LOG.debug("String_Node_Str" + imgInfo + "String_Node_Str"+ root);
            Volume vol=Volumes.createStorageVolume(sc,this.allocInfo.getOwnerFullName(),imgInfo.getSnapshotId(),sizeGb,allocInfo.getRequest());
            if (imgInfo.getDeleteOnTerminate()) {
              this.allocInfo.getTransientVolumes().add(vol);
            }
 else {
              this.allocInfo.getPersistentVolumes().add(vol);
            }
          }
        }
      }
      for (      NetworkToken networkToken : vmToken.getNetworkTokens())       this.setupNetworkMessages(networkToken);
      this.setupVmMessages(vmToken);
    }
 catch (    Throwable e) {
      LOG.debug(e,e);
      try {
        Clusters.getInstance().lookup(vmToken.getCluster()).getNodeState().releaseToken(vmToken);
      }
 catch (      Throwable e1) {
        LOG.debug(e1);
        LOG.trace(e1,e1);
      }
      for (      String addr : vmToken.getAddresses()) {
        try {
          Addresses.release(Addresses.getInstance().lookup(addr));
        }
 catch (        Throwable e1) {
          LOG.debug(e1);
          LOG.trace(e1,e1);
        }
      }
      try {
        if (vmToken.getPrimaryNetwork() != null) {
          Network net=Networks.getInstance().lookup(vmToken.getPrimaryNetwork().getName());
          for (          Integer i : vmToken.getPrimaryNetwork().getIndexes()) {
            net.returnNetworkIndex(i);
          }
        }
      }
 catch (      Throwable e1) {
        LOG.debug(e1);
        LOG.trace(e1,e1);
      }
      for (      String vmId : vmToken.getInstanceIds()) {
        try {
          VmInstance vm=VmInstances.getInstance().lookup(vmId);
          vm.setState(VmState.TERMINATED,Reason.FAILED,e.getMessage());
          VmInstances.getInstance().disable(vmId);
        }
 catch (        Exception e1) {
          LOG.debug(e1,e1);
        }
      }
    }
  }
}