Program: 106339
Project: 106339
Buggy source:
public boolean createLinkedClone(String cloneName,ManagedObjectReference morBaseSnapshot,ManagedObjectReference morFolder,ManagedObjectReference morResourcePool,ManagedObjectReference morDs) throws Exception {
  assert(morBaseSnapshot != null);
  assert(morFolder != null);
  assert(morResourcePool != null);
  assert(morDs != null);
  VirtualDisk[] independentDisks=getAllIndependentDiskDevice();
  VirtualMachineRelocateSpec rSpec=new VirtualMachineRelocateSpec();
  if (independentDisks.length > 0) {
    List<VirtualMachineRelocateSpecDiskLocator> diskLocator=new ArrayList<VirtualMachineRelocateSpecDiskLocator>(independentDisks.length);
    for (int i=0; i < independentDisks.length; i++) {
      VirtualMachineRelocateSpecDiskLocator loc=new VirtualMachineRelocateSpecDiskLocator();
      loc.setDatastore(morDs);
      loc.setDiskId(independentDisks[i].getKey());
      loc.setDiskMoveType(VirtualMachineRelocateDiskMoveOptions.MOVE_ALL_DISK_BACKINGS_AND_DISALLOW_SHARING.toString());
      diskLocator.add(loc);
    }
    rSpec.setDiskMoveType(VirtualMachineRelocateDiskMoveOptions.CREATE_NEW_CHILD_DISK_BACKING.toString());
    rSpec.getDisk().addAll(diskLocator);
  }
 else {
    rSpec.setDiskMoveType(VirtualMachineRelocateDiskMoveOptions.CREATE_NEW_CHILD_DISK_BACKING.toString());
  }
  rSpec.setPool(morResourcePool);
  VirtualMachineCloneSpec cloneSpec=new VirtualMachineCloneSpec();
  cloneSpec.setPowerOn(false);
  cloneSpec.setTemplate(false);
  cloneSpec.setLocation(rSpec);
  cloneSpec.setSnapshot(morBaseSnapshot);
  ManagedObjectReference morTask=_context.getService().cloneVMTask(_mor,morFolder,cloneName,cloneSpec);
  boolean result=_context.getVimClient().waitForTask(morTask);
  if (result) {
    _context.waitForTaskProgressDone(morTask);
    return true;
  }
 else {
    s_logger.error("String_Node_Str" + TaskMO.getTaskFailureInfo(_context,morTask));
  }
  return false;
}

Fixed version (ground truth):
public boolean createLinkedClone(String cloneName,ManagedObjectReference morBaseSnapshot,ManagedObjectReference morFolder,ManagedObjectReference morResourcePool,ManagedObjectReference morDs) throws Exception {
  assert(morBaseSnapshot != null);
  assert(morFolder != null);
  assert(morResourcePool != null);
  assert(morDs != null);
  VirtualDisk[] independentDisks=getAllIndependentDiskDevice();
  VirtualMachineRelocateSpec rSpec=new VirtualMachineRelocateSpec();
  if (independentDisks.length > 0) {
    List<VirtualMachineRelocateSpecDiskLocator> diskLocator=new ArrayList<VirtualMachineRelocateSpecDiskLocator>(independentDisks.length);
    for (int i=0; i < independentDisks.length; i++) {
      VirtualMachineRelocateSpecDiskLocator loc=new VirtualMachineRelocateSpecDiskLocator();
      loc.setDatastore(morDs);
      loc.setDiskId(independentDisks[i].getKey());
      loc.setDiskMoveType(VirtualMachineRelocateDiskMoveOptions.MOVE_ALL_DISK_BACKINGS_AND_DISALLOW_SHARING.value());
      diskLocator.add(loc);
    }
    rSpec.setDiskMoveType(VirtualMachineRelocateDiskMoveOptions.CREATE_NEW_CHILD_DISK_BACKING.value());
    rSpec.getDisk().addAll(diskLocator);
  }
 else {
    rSpec.setDiskMoveType(VirtualMachineRelocateDiskMoveOptions.CREATE_NEW_CHILD_DISK_BACKING.value());
  }
  rSpec.setPool(morResourcePool);
  VirtualMachineCloneSpec cloneSpec=new VirtualMachineCloneSpec();
  cloneSpec.setPowerOn(false);
  cloneSpec.setTemplate(false);
  cloneSpec.setLocation(rSpec);
  cloneSpec.setSnapshot(morBaseSnapshot);
  ManagedObjectReference morTask=_context.getService().cloneVMTask(_mor,morFolder,cloneName,cloneSpec);
  boolean result=_context.getVimClient().waitForTask(morTask);
  if (result) {
    _context.waitForTaskProgressDone(morTask);
    return true;
  }
 else {
    s_logger.error("String_Node_Str" + TaskMO.getTaskFailureInfo(_context,morTask));
  }
  return false;
}