Program: 106177
Project: 106177
Buggy source:
@Override public void create() throws ResourceAllocationException {
  try {
    Account owner=_accountService.getActiveAccountById(getEntityOwnerId());
    DataCenter zone=_entityMgr.findById(DataCenter.class,zoneId);
    if (zone == null) {
      throw new InvalidParameterValueException("String_Node_Str" + zoneId);
    }
    ServiceOffering serviceOffering=_configService.getServiceOffering(serviceOfferingId);
    if (serviceOffering == null) {
      throw new InvalidParameterValueException("String_Node_Str" + serviceOfferingId);
    }
    VirtualMachineTemplate template=_templateService.getTemplate(templateId);
    if (template == null) {
      throw new InvalidParameterValueException("String_Node_Str" + templateId);
    }
    DiskOffering diskOffering=null;
    if (diskOfferingId != null) {
      diskOffering=_configService.getDiskOffering(diskOfferingId);
      if (diskOffering == null) {
        throw new InvalidParameterValueException("String_Node_Str" + diskOfferingId);
      }
    }
    if (!zone.isLocalStorageEnabled()) {
      if (serviceOffering.getUseLocalStorage()) {
        throw new InvalidParameterValueException("String_Node_Str" + serviceOffering.getName() + "String_Node_Str");
      }
      if (diskOffering != null && diskOffering.getUseLocalStorage()) {
        throw new InvalidParameterValueException("String_Node_Str" + diskOffering.getName() + "String_Node_Str");
      }
    }
    UserVm vm=null;
    IpAddresses addrs=new IpAddresses(ipAddress,getIp6Address());
    if (zone.getNetworkType() == NetworkType.Basic) {
      if (getNetworkIds() != null) {
        throw new InvalidParameterValueException("String_Node_Str");
      }
 else {
        vm=_userVmService.createBasicSecurityGroupVirtualMachine(zone,serviceOffering,template,getSecurityGroupIdList(),owner,name,displayName,diskOfferingId,size,group,getHypervisor(),this.getHttpMethod(),userData,sshKeyPairName,getIpToNetworkMap(),addrs,displayVm,keyboard,getAffinityGroupIdList());
      }
    }
 else {
      if (zone.isSecurityGroupEnabled()) {
        vm=_userVmService.createAdvancedSecurityGroupVirtualMachine(zone,serviceOffering,template,getNetworkIds(),getSecurityGroupIdList(),owner,name,displayName,diskOfferingId,size,group,getHypervisor(),this.getHttpMethod(),userData,sshKeyPairName,getIpToNetworkMap(),addrs,displayVm,keyboard,getAffinityGroupIdList());
      }
 else {
        if (getSecurityGroupIdList() != null && !getSecurityGroupIdList().isEmpty()) {
          throw new InvalidParameterValueException("String_Node_Str");
        }
        vm=_userVmService.createAdvancedVirtualMachine(zone,serviceOffering,template,getNetworkIds(),owner,name,displayName,diskOfferingId,size,group,getHypervisor(),this.getHttpMethod(),userData,sshKeyPairName,getIpToNetworkMap(),addrs,displayVm,keyboard,getAffinityGroupIdList());
      }
    }
    if (vm != null) {
      setEntityId(vm.getId());
      setEntityUuid(vm.getUuid());
    }
 else {
      throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,"String_Node_Str");
    }
  }
 catch (  InsufficientCapacityException ex) {
    s_logger.info(ex);
    s_logger.trace(ex.getMessage(),ex);
    throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR,ex.getMessage());
  }
catch (  ResourceUnavailableException ex) {
    s_logger.warn("String_Node_Str",ex);
    throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR,ex.getMessage());
  }
catch (  ConcurrentOperationException ex) {
    s_logger.warn("String_Node_Str",ex);
    throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,ex.getMessage());
  }
}

Fixed version (ground truth):
@Override public void create() throws ResourceAllocationException {
  try {
    Account owner=_accountService.getActiveAccountById(getEntityOwnerId());
    DataCenter zone=_entityMgr.findById(DataCenter.class,zoneId);
    if (zone == null) {
      throw new InvalidParameterValueException("String_Node_Str" + zoneId);
    }
    ServiceOffering serviceOffering=_entityMgr.findById(ServiceOffering.class,serviceOfferingId);
    if (serviceOffering == null) {
      throw new InvalidParameterValueException("String_Node_Str" + serviceOfferingId);
    }
    VirtualMachineTemplate template=_templateService.getTemplate(templateId);
    if (template == null) {
      throw new InvalidParameterValueException("String_Node_Str" + templateId);
    }
    DiskOffering diskOffering=null;
    if (diskOfferingId != null) {
      diskOffering=_entityMgr.findById(DiskOffering.class,diskOfferingId);
      if (diskOffering == null) {
        throw new InvalidParameterValueException("String_Node_Str" + diskOfferingId);
      }
    }
    if (!zone.isLocalStorageEnabled()) {
      if (serviceOffering.getUseLocalStorage()) {
        throw new InvalidParameterValueException("String_Node_Str" + serviceOffering.getName() + "String_Node_Str");
      }
      if (diskOffering != null && diskOffering.getUseLocalStorage()) {
        throw new InvalidParameterValueException("String_Node_Str" + diskOffering.getName() + "String_Node_Str");
      }
    }
    UserVm vm=null;
    IpAddresses addrs=new IpAddresses(ipAddress,getIp6Address());
    if (zone.getNetworkType() == NetworkType.Basic) {
      if (getNetworkIds() != null) {
        throw new InvalidParameterValueException("String_Node_Str");
      }
 else {
        vm=_userVmService.createBasicSecurityGroupVirtualMachine(zone,serviceOffering,template,getSecurityGroupIdList(),owner,name,displayName,diskOfferingId,size,group,getHypervisor(),getHttpMethod(),userData,sshKeyPairName,getIpToNetworkMap(),addrs,displayVm,keyboard,getAffinityGroupIdList());
      }
    }
 else {
      if (zone.isSecurityGroupEnabled()) {
        vm=_userVmService.createAdvancedSecurityGroupVirtualMachine(zone,serviceOffering,template,getNetworkIds(),getSecurityGroupIdList(),owner,name,displayName,diskOfferingId,size,group,getHypervisor(),getHttpMethod(),userData,sshKeyPairName,getIpToNetworkMap(),addrs,displayVm,keyboard,getAffinityGroupIdList());
      }
 else {
        if (getSecurityGroupIdList() != null && !getSecurityGroupIdList().isEmpty()) {
          throw new InvalidParameterValueException("String_Node_Str");
        }
        vm=_userVmService.createAdvancedVirtualMachine(zone,serviceOffering,template,getNetworkIds(),owner,name,displayName,diskOfferingId,size,group,getHypervisor(),getHttpMethod(),userData,sshKeyPairName,getIpToNetworkMap(),addrs,displayVm,keyboard,getAffinityGroupIdList());
      }
    }
    if (vm != null) {
      setEntityId(vm.getId());
      setEntityUuid(vm.getUuid());
    }
 else {
      throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,"String_Node_Str");
    }
  }
 catch (  InsufficientCapacityException ex) {
    s_logger.info(ex);
    s_logger.trace(ex.getMessage(),ex);
    throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR,ex.getMessage());
  }
catch (  ResourceUnavailableException ex) {
    s_logger.warn("String_Node_Str",ex);
    throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR,ex.getMessage());
  }
catch (  ConcurrentOperationException ex) {
    s_logger.warn("String_Node_Str",ex);
    throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,ex.getMessage());
  }
}