Program: 105343
Project: 105343
Buggy source:
private void postDiskConfigBeforeStart(VirtualMachineMO vmMo,VirtualMachineTO vmSpec,DiskTO[] sortedDisks,int ideControllerKey,int scsiControllerKey,Map<String,String> iqnToPath,VmwareHypervisorHost hyperHost,VmwareContext context) throws Exception {
  VirtualMachineDiskInfoBuilder diskInfoBuilder=vmMo.getDiskInfoBuilder();
  for (  DiskTO vol : sortedDisks) {
    if (vol.getType() == Volume.Type.ISO)     continue;
    VolumeObjectTO volumeTO=(VolumeObjectTO)vol.getData();
    VirtualMachineDiskInfo diskInfo=getMatchingExistingDisk(diskInfoBuilder,vol,hyperHost,context);
    assert(diskInfo != null);
    String[] diskChain=diskInfo.getDiskChain();
    assert(diskChain.length > 0);
    Map<String,String> details=vol.getDetails();
    boolean managed=false;
    if (details != null) {
      managed=Boolean.parseBoolean(details.get(DiskTO.MANAGED));
    }
    DatastoreFile file=new DatastoreFile(diskChain[0]);
    if (managed) {
      DatastoreFile originalFile=new DatastoreFile(volumeTO.getPath());
      if (!file.getFileBaseName().equalsIgnoreCase(originalFile.getFileBaseName())) {
        if (s_logger.isInfoEnabled())         s_logger.info("String_Node_Str" + volumeTO.getId() + "String_Node_Str"+ volumeTO.getPath()+ "String_Node_Str"+ diskChain[0]);
      }
    }
 else {
      if (!file.getFileBaseName().equalsIgnoreCase(volumeTO.getPath())) {
        if (s_logger.isInfoEnabled())         s_logger.info("String_Node_Str" + volumeTO.getId() + "String_Node_Str"+ volumeTO.getPath()+ "String_Node_Str"+ file.getFileBaseName());
      }
    }
    VolumeObjectTO volInSpec=getVolumeInSpec(vmSpec,volumeTO);
    if (managed) {
      String datastoreVolumePath=diskChain[0];
      iqnToPath.put(details.get(DiskTO.IQN),datastoreVolumePath);
      vol.setPath(datastoreVolumePath);
      volumeTO.setPath(datastoreVolumePath);
      volInSpec.setPath(datastoreVolumePath);
    }
 else {
      volInSpec.setPath(file.getFileBaseName());
    }
    volInSpec.setChainInfo(_gson.toJson(diskInfo));
  }
}

Fixed version (ground truth):
private void postDiskConfigBeforeStart(VirtualMachineMO vmMo,VirtualMachineTO vmSpec,DiskTO[] sortedDisks,int ideControllerKey,int scsiControllerKey,Map<String,String> iqnToPath,VmwareHypervisorHost hyperHost,VmwareContext context) throws Exception {
  VirtualMachineDiskInfoBuilder diskInfoBuilder=vmMo.getDiskInfoBuilder();
  for (  DiskTO vol : sortedDisks) {
    if (vol.getType() == Volume.Type.ISO)     continue;
    VolumeObjectTO volumeTO=(VolumeObjectTO)vol.getData();
    VirtualMachineDiskInfo diskInfo=getMatchingExistingDisk(diskInfoBuilder,vol,hyperHost,context);
    assert(diskInfo != null);
    String[] diskChain=diskInfo.getDiskChain();
    assert(diskChain.length > 0);
    Map<String,String> details=vol.getDetails();
    boolean managed=false;
    if (details != null) {
      managed=Boolean.parseBoolean(details.get(DiskTO.MANAGED));
    }
    DatastoreFile file=new DatastoreFile(diskChain[0]);
    if (managed) {
      DatastoreFile originalFile=new DatastoreFile(volumeTO.getPath());
      if (!file.getFileBaseName().equalsIgnoreCase(originalFile.getFileBaseName())) {
        if (s_logger.isInfoEnabled())         s_logger.info("String_Node_Str" + volumeTO.getId() + "String_Node_Str"+ volumeTO.getPath()+ "String_Node_Str"+ diskChain[0]);
      }
    }
 else {
      if (!file.getFileBaseName().equalsIgnoreCase(volumeTO.getPath())) {
        if (s_logger.isInfoEnabled())         s_logger.info("String_Node_Str" + volumeTO.getId() + "String_Node_Str"+ volumeTO.getPath()+ "String_Node_Str"+ file.getFileBaseName());
      }
    }
    VolumeObjectTO volInSpec=getVolumeInSpec(vmSpec,volumeTO);
    if (volInSpec != null) {
      if (managed) {
        String datastoreVolumePath=diskChain[0];
        iqnToPath.put(details.get(DiskTO.IQN),datastoreVolumePath);
        vol.setPath(datastoreVolumePath);
        volumeTO.setPath(datastoreVolumePath);
        volInSpec.setPath(datastoreVolumePath);
      }
 else {
        volInSpec.setPath(file.getFileBaseName());
      }
      volInSpec.setChainInfo(_gson.toJson(diskInfo));
    }
  }
}