Program: 30323
Project: 30323
Buggy source:
public ListenableFuture<AllocationPhase,VirtualMachine> create(final TemplateInstance template,final VirtualCluster cluster,final EventSource<AllocationPhase> source) throws VirtException, IOException {
  populate();
  source.fireEvent(AllocationPhase.VM_PREPARE);
  final String name=cluster.getConfig().getName() + cluster.allocateToken();
  File xml=template.getFileByExtension("String_Node_Str");
  Element vmConfig=loadConfigFile(xml);
  List<StorageVol> volumes=prepare(template,name,cluster);
  File machineDisks=absolutize(new File(virtualizations.getDisksLocation(),serverPool.getName()));
  machineDisks=new File(machineDisks,getName());
  File custDirectory=prepareCustDirectory(name,cluster.getConfig(),template.getConfig());
  File custFile=new File(machineDisks,name + "String_Node_Str");
  prepareCustomization(custDirectory,custFile,name);
  final String diskLocation=config.getDisksLocation();
  delete(diskLocation + "String_Node_Str" + custFile.getName());
  copy(custFile,new File(diskLocation));
  OsInterface os=services.forContract(OsInterface.class).get();
  String uuid=UUID.randomUUID().toString();
  String macAddress=os.macAddressGen();
  vmConfig.setAttribute("String_Node_Str",getVirtualizationConfig().getName());
  NodeList children=vmConfig.getChildNodes();
  for (int k=0; k < children.getLength(); k++) {
    Node node=children.item(k);
    if (node.getNodeName().equals("String_Node_Str")) {
      node.getChildNodes().item(0).setNodeValue(name);
    }
    if (node.getNodeName().equals("String_Node_Str")) {
      node.getChildNodes().item(0).setNodeValue(uuid);
    }
    if (node.getNodeName().equals("String_Node_Str")) {
      NodeList devices=node.getChildNodes();
      for (int i=0; i < devices.getLength(); i++) {
        Node device=devices.item(i);
        if (device.getNodeName().equals("String_Node_Str")) {
          node.removeChild(device);
        }
        if (device.getNodeName().equals("String_Node_Str") && device.getAttributes().getNamedItem("String_Node_Str").getNodeValue().equals("String_Node_Str")) {
          NodeList intfInfos=device.getChildNodes();
          for (int j=0; j < intfInfos.getLength(); j++) {
            if (intfInfos.item(j).getNodeName().equals("String_Node_Str")) {
              intfInfos.item(j).getAttributes().getNamedItem("String_Node_Str").setNodeValue(macAddress);
            }
          }
        }
        if (device.getNodeName().equals("String_Node_Str")) {
          device.getChildNodes().item(0).setNodeValue(getVirtualizationConfig().getEmulatorPath());
        }
      }
      int position=0;
      for (      StorageVol aVol : volumes) {
        if (aVol instanceof LibVirtStorageVol) {
          Node newNode=((LibVirtStorageVol)aVol).getXML(node,position++);
          node.appendChild(newNode);
        }
      }
      DiskReference cdRom=new CDRomDisk();
      Node cdRomNode=cdRom.save(this.getUserHome() + "String_Node_Str" + config.getDisksLocation()+ "String_Node_Str"+ custFile.getName(),node,0);
      node.appendChild(cdRomNode);
    }
  }
  File destXml=new File(System.getProperty("String_Node_Str"),"String_Node_Str");
  writeConfig(vmConfig,destXml);
  System.out.println("String_Node_Str" + uuid + "String_Node_Str"+ macAddress);
  try {
    Domain domain=connection().domainDefineXML(getConfig(vmConfig));
    source.fireEvent(AllocationPhase.VM_SPAWN);
    final CountDownLatch latch=vmLifecycle.inStartup(name);
    final LibVirtVirtualMachine vm=new LibVirtVirtualMachine(this,domain);
    domains.put(name,vm);
    cluster.add(template,vm);
    ListenableFutureImpl<AllocationPhase,VirtualMachine> future=new ListenableFutureImpl<AllocationPhase,VirtualMachine>(latch,vm,source);
    future.fireEvent(AllocationPhase.VM_START);
    vmLifecycle.start(vm);
    return future;
  }
 catch (  VirtException e) {
    for (    StorageVol volume : volumes) {
      volume.delete();
    }
    throw new VirtException(e);
  }
}

Fixed version (ground truth):
public ListenableFuture<AllocationPhase,VirtualMachine> create(final TemplateInstance template,final VirtualCluster cluster,final EventSource<AllocationPhase> source) throws VirtException, IOException {
  populate();
  source.fireEvent(AllocationPhase.VM_PREPARE);
  final String name=cluster.getConfig().getName() + cluster.allocateToken();
  File xml=template.getFileByExtension("String_Node_Str");
  Element vmConfig=loadConfigFile(xml);
  List<StorageVol> volumes=prepare(template,name,cluster);
  File machineDisks=absolutize(new File(virtualizations.getDisksLocation(),serverPool.getName()));
  machineDisks=new File(machineDisks,getName());
  File custDirectory=prepareCustDirectory(name,cluster.getConfig(),template.getConfig());
  File custFile=new File(machineDisks,name + "String_Node_Str");
  prepareCustomization(custDirectory,custFile,name);
  final String diskLocation=config.getDisksLocation();
  delete(diskLocation + "String_Node_Str" + custFile.getName());
  copy(custFile,new File(diskLocation));
  OsInterface os=services.forContract(OsInterface.class).get();
  String uuid=UUID.randomUUID().toString();
  String macAddress=os.macAddressGen();
  vmConfig.setAttribute("String_Node_Str",getVirtualizationConfig().getName());
  NodeList children=vmConfig.getChildNodes();
  for (int k=0; k < children.getLength(); k++) {
    Node node=children.item(k);
    if (node.getNodeName().equals("String_Node_Str")) {
      node.getChildNodes().item(0).setNodeValue(name);
    }
    if (node.getNodeName().equals("String_Node_Str")) {
      node.getChildNodes().item(0).setNodeValue(uuid);
    }
    if (node.getNodeName().equals("String_Node_Str")) {
      NodeList devices=node.getChildNodes();
      for (int i=0; i < devices.getLength(); i++) {
        Node device=devices.item(i);
        if (device.getNodeName().equals("String_Node_Str")) {
          node.removeChild(device);
        }
        if (device.getNodeName().equals("String_Node_Str") && device.getAttributes().getNamedItem("String_Node_Str").getNodeValue().equals("String_Node_Str")) {
          NodeList intfInfos=device.getChildNodes();
          for (int j=0; j < intfInfos.getLength(); j++) {
            if (intfInfos.item(j).getNodeName().equals("String_Node_Str")) {
              intfInfos.item(j).getAttributes().getNamedItem("String_Node_Str").setNodeValue(macAddress);
            }
          }
        }
        if (device.getNodeName().equals("String_Node_Str")) {
          device.getChildNodes().item(0).setNodeValue(getVirtualizationConfig().getEmulatorPath());
        }
      }
      int position=0;
      for (      StorageVol aVol : volumes) {
        if (aVol instanceof LibVirtStorageVol) {
          Node newNode=((LibVirtStorageVol)aVol).getXML(node,position++);
          node.appendChild(newNode);
        }
      }
      DiskReference cdRom=new CDRomDisk();
      Node cdRomNode=cdRom.save(this.getUserHome() + "String_Node_Str" + config.getDisksLocation()+ "String_Node_Str"+ custFile.getName(),node,0);
      node.appendChild(cdRomNode);
    }
  }
  File destXml=new File(System.getProperty("String_Node_Str"),"String_Node_Str");
  writeConfig(vmConfig,destXml);
  System.out.println("String_Node_Str" + uuid + "String_Node_Str"+ macAddress);
  try {
    Domain domain=connection().domainDefineXML(getConfig(vmConfig));
    source.fireEvent(AllocationPhase.VM_SPAWN);
    final CountDownLatch latch=vmLifecycle.inStartup(name);
    final LibVirtVirtualMachine vm=new LibVirtVirtualMachine(template.getConfig().getUser(),this,domain,volumes);
    domains.put(name,vm);
    cluster.add(template,vm);
    ListenableFutureImpl<AllocationPhase,VirtualMachine> future=new ListenableFutureImpl<AllocationPhase,VirtualMachine>(latch,vm,source);
    future.fireEvent(AllocationPhase.VM_START);
    vmLifecycle.start(vm);
    return future;
  }
 catch (  VirtException e) {
    for (    StorageVol volume : volumes) {
      volume.delete();
    }
    throw new VirtException(e);
  }
}