Program: 106320
Project: 106320
Buggy source:
@Override public VirtualMachineEntity createVirtualMachineFromScratch(String id,String owner,String isoId,String hostName,String displayName,String hypervisor,String os,int cpu,int speed,long memory,Long diskSize,List<String> computeTags,List<String> rootDiskTags,Map<String,NicProfile> networkNicMap,DeploymentPlan plan) throws InsufficientCapacityException {
  VirtualMachineEntityImpl vmEntity=null;
  try {
    vmEntity=_vmEntityFactory.getObject();
  }
 catch (  Exception e) {
  }
  vmEntity.init(id,owner,hostName,displayName,cpu,speed,memory,computeTags,rootDiskTags,new ArrayList<String>(networkNicMap.keySet()));
  VMInstanceVO vm=_vmDao.findByUuid(id);
  Pair<DiskOfferingVO,Long> rootDiskOffering=new Pair<DiskOfferingVO,Long>(null,null);
  ServiceOfferingVO offering=_serviceOfferingDao.findById(vm.getServiceOfferingId());
  rootDiskOffering.first(offering);
  List<Pair<DiskOfferingVO,Long>> dataDiskOfferings=new ArrayList<Pair<DiskOfferingVO,Long>>();
  Long diskOfferingId=vm.getDiskOfferingId();
  if (diskOfferingId == null) {
    throw new InvalidParameterValueException("String_Node_Str");
  }
  DiskOfferingVO diskOffering=_diskOfferingDao.findById(diskOfferingId);
  if (diskOffering == null) {
    throw new InvalidParameterValueException("String_Node_Str" + diskOfferingId);
  }
  Long size=null;
  if (diskOffering.getDiskSize() == 0) {
    size=diskSize;
    if (size == null) {
      throw new InvalidParameterValueException("String_Node_Str" + diskOffering + "String_Node_Str");
    }
  }
  rootDiskOffering.first(diskOffering);
  rootDiskOffering.second(size);
  HypervisorType hypervisorType=HypervisorType.valueOf(hypervisor);
  if (_itMgr.allocate(vm,_templateDao.findById(new Long(isoId)),offering,rootDiskOffering,dataDiskOfferings,null,null,plan,hypervisorType,null) == null) {
    return null;
  }
  return vmEntity;
}

Fixed version (ground truth):
@Override public VirtualMachineEntity createVirtualMachineFromScratch(String id,String owner,String isoId,String hostName,String displayName,String hypervisor,String os,int cpu,int speed,long memory,Long diskSize,List<String> computeTags,List<String> rootDiskTags,Map<String,NicProfile> networkNicMap,DeploymentPlan plan) throws InsufficientCapacityException {
  VirtualMachineEntityImpl vmEntity=null;
  try {
    vmEntity=_vmEntityFactory.getObject();
  }
 catch (  Exception e) {
  }
  vmEntity.init(id,owner,hostName,displayName,cpu,speed,memory,computeTags,rootDiskTags,new ArrayList<String>(networkNicMap.keySet()));
  VMInstanceVO vm=_vmDao.findByUuid(id);
  Pair<DiskOfferingVO,Long> rootDiskOffering=new Pair<DiskOfferingVO,Long>(null,null);
  ServiceOfferingVO offering=_serviceOfferingDao.findById(vm.getServiceOfferingId());
  rootDiskOffering.first(offering);
  List<Pair<DiskOfferingVO,Long>> dataDiskOfferings=new ArrayList<Pair<DiskOfferingVO,Long>>();
  Long diskOfferingId=vm.getDiskOfferingId();
  if (diskOfferingId == null) {
    throw new InvalidParameterValueException("String_Node_Str");
  }
  DiskOfferingVO diskOffering=_diskOfferingDao.findById(diskOfferingId);
  if (diskOffering == null) {
    throw new InvalidParameterValueException("String_Node_Str" + diskOfferingId);
  }
  Long size=null;
  if (diskOffering.getDiskSize() == 0) {
    size=diskSize;
    if (size == null) {
      throw new InvalidParameterValueException("String_Node_Str" + diskOffering + "String_Node_Str");
    }
  }
  rootDiskOffering.first(diskOffering);
  rootDiskOffering.second(size);
  List<Pair<NetworkVO,NicProfile>> networkIpMap=new ArrayList<Pair<NetworkVO,NicProfile>>();
  for (  String uuid : networkNicMap.keySet()) {
    NetworkVO network=_networkDao.findByUuid(uuid);
    if (network != null) {
      networkIpMap.add(new Pair<NetworkVO,NicProfile>(network,networkNicMap.get(uuid)));
    }
  }
  HypervisorType hypervisorType=HypervisorType.valueOf(hypervisor);
  if (_itMgr.allocate(_userVmDao.findById(vm.getId(),true),_templateDao.findById(new Long(isoId)),offering,rootDiskOffering,dataDiskOfferings,networkIpMap,null,plan,hypervisorType,_accountDao.findById(new Long(owner))) == null) {
    return null;
  }
  return vmEntity;
}