Program: 105519
Project: 105519
Buggy source:
private VirtualMachineDiskInfo getMatchingExistingDisk(VirtualMachineDiskInfoBuilder diskInfoBuilder,DiskTO vol){
  if (diskInfoBuilder != null) {
    VolumeObjectTO volume=(VolumeObjectTO)vol.getData();
    String dsName=volume.getDataStore().getUuid().replace("String_Node_Str","String_Node_Str");
    Map<String,String> details=vol.getDetails();
    boolean isManaged=details != null && Boolean.parseBoolean(details.get(DiskTO.MANAGED));
    VirtualMachineDiskInfo diskInfo=diskInfoBuilder.getDiskInfoByBackingFileBaseName(isManaged ? new DatastoreFile(volume.getPath()).getFileBaseName() : volume.getPath(),dsName);
    if (diskInfo != null) {
      s_logger.info("String_Node_Str" + volume.getPath());
      return diskInfo;
    }
 else {
      String chainInfo=volume.getChainInfo();
      if (chainInfo != null) {
        VirtualMachineDiskInfo infoInChain=_gson.fromJson(chainInfo,VirtualMachineDiskInfo.class);
        if (infoInChain != null) {
          String[] disks=infoInChain.getDiskChain();
          if (disks.length > 0) {
            for (            String diskPath : disks) {
              DatastoreFile file=new DatastoreFile(diskPath);
              diskInfo=diskInfoBuilder.getDiskInfoByBackingFileBaseName(file.getFileBaseName(),dsName);
              if (diskInfo != null) {
                s_logger.info("String_Node_Str" + diskPath);
                return diskInfo;
              }
            }
          }
          if (diskInfo == null) {
            diskInfo=diskInfoBuilder.getDiskInfoByDeviceBusName(infoInChain.getDiskDeviceBusName());
            if (diskInfo != null) {
              s_logger.info("String_Node_Str" + infoInChain.getDiskDeviceBusName());
              return diskInfo;
            }
          }
        }
      }
    }
  }
  return null;
}

Fixed version (ground truth):
private VirtualMachineDiskInfo getMatchingExistingDisk(VirtualMachineDiskInfoBuilder diskInfoBuilder,DiskTO vol,VmwareHypervisorHost hyperHost,VmwareContext context) throws Exception {
  if (diskInfoBuilder != null) {
    VolumeObjectTO volume=(VolumeObjectTO)vol.getData();
    ManagedObjectReference morDs=HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost,volume.getDataStore().getUuid());
    DatastoreMO dsMo=new DatastoreMO(context,morDs);
    String dsName=dsMo.getName();
    Map<String,String> details=vol.getDetails();
    boolean isManaged=details != null && Boolean.parseBoolean(details.get(DiskTO.MANAGED));
    VirtualMachineDiskInfo diskInfo=diskInfoBuilder.getDiskInfoByBackingFileBaseName(isManaged ? new DatastoreFile(volume.getPath()).getFileBaseName() : volume.getPath(),dsName);
    if (diskInfo != null) {
      s_logger.info("String_Node_Str" + volume.getPath());
      return diskInfo;
    }
 else {
      String chainInfo=volume.getChainInfo();
      if (chainInfo != null) {
        VirtualMachineDiskInfo infoInChain=_gson.fromJson(chainInfo,VirtualMachineDiskInfo.class);
        if (infoInChain != null) {
          String[] disks=infoInChain.getDiskChain();
          if (disks.length > 0) {
            for (            String diskPath : disks) {
              DatastoreFile file=new DatastoreFile(diskPath);
              diskInfo=diskInfoBuilder.getDiskInfoByBackingFileBaseName(file.getFileBaseName(),dsName);
              if (diskInfo != null) {
                s_logger.info("String_Node_Str" + diskPath);
                return diskInfo;
              }
            }
          }
          if (diskInfo == null) {
            diskInfo=diskInfoBuilder.getDiskInfoByDeviceBusName(infoInChain.getDiskDeviceBusName());
            if (diskInfo != null) {
              s_logger.info("String_Node_Str" + infoInChain.getDiskDeviceBusName());
              return diskInfo;
            }
          }
        }
      }
    }
  }
  return null;
}