Program: 106777
Project: 106777
Buggy source:
@Override public void create() throws ResourceAllocationException {
  try {
    Account owner=_accountService.getActiveAccount(getAccountName(),getDomainId());
    if (owner == null) {
      throw new InvalidParameterValueException("String_Node_Str" + accountName + "String_Node_Str"+ domainId);
    }
    DataCenter zone=_configService.getZone(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);
    }
    if (diskOfferingId != null) {
      DiskOffering diskOffering=_configService.getDiskOffering(diskOfferingId);
      if (diskOffering == null) {
        throw new InvalidParameterValueException("String_Node_Str" + diskOfferingId);
      }
    }
    UserVm vm=null;
    if (getHypervisor() == HypervisorType.BareMetal) {
      vm=_bareMetalVmService.createVirtualMachine(this);
    }
 else {
      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(),userData,sshKeyPairName,getIpToNetworkMap(),ipAddress);
        }
      }
 else {
        if (zone.isSecurityGroupEnabled()) {
          vm=_userVmService.createAdvancedSecurityGroupVirtualMachine(zone,serviceOffering,template,getNetworkIds(),getSecurityGroupIdList(),owner,name,displayName,diskOfferingId,size,group,getHypervisor(),userData,sshKeyPairName,getIpToNetworkMap(),ipAddress);
        }
 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(),userData,sshKeyPairName,getIpToNetworkMap(),ipAddress);
        }
      }
    }
    if (vm != null) {
      setEntityId(vm.getId());
    }
 else {
      throw new ServerApiException(BaseCmd.INTERNAL_ERROR,"String_Node_Str");
    }
  }
 catch (  InsufficientCapacityException ex) {
    s_logger.info(ex);
    s_logger.trace(ex);
    throw new ServerApiException(BaseCmd.INSUFFICIENT_CAPACITY_ERROR,ex.getMessage());
  }
catch (  ResourceUnavailableException ex) {
    s_logger.warn("String_Node_Str",ex);
    throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR,ex.getMessage());
  }
catch (  ConcurrentOperationException ex) {
    s_logger.warn("String_Node_Str",ex);
    throw new ServerApiException(BaseCmd.INTERNAL_ERROR,ex.getMessage());
  }
}

Fixed version (ground truth):
@Override public void create() throws ResourceAllocationException {
  try {
    Account owner=_accountService.getActiveAccount(getAccountName(),getDomainId());
    if (owner == null) {
      throw new InvalidParameterValueException("String_Node_Str" + accountName + "String_Node_Str"+ domainId);
    }
    DataCenter zone=_configService.getZone(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);
    }
    if (diskOfferingId != null) {
      DiskOffering diskOffering=_configService.getDiskOffering(diskOfferingId);
      if (diskOffering == null) {
        throw new InvalidParameterValueException("String_Node_Str" + diskOfferingId);
      }
    }
    UserVm vm=null;
    if (getHypervisor() == HypervisorType.BareMetal) {
      vm=_bareMetalVmService.createVirtualMachine(this);
    }
 else {
      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(),userData,sshKeyPairName,getIpToNetworkMap(),ipAddress,keyboard);
        }
      }
 else {
        if (zone.isSecurityGroupEnabled()) {
          vm=_userVmService.createAdvancedSecurityGroupVirtualMachine(zone,serviceOffering,template,getNetworkIds(),getSecurityGroupIdList(),owner,name,displayName,diskOfferingId,size,group,getHypervisor(),userData,sshKeyPairName,getIpToNetworkMap(),ipAddress,keyboard);
        }
 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(),userData,sshKeyPairName,getIpToNetworkMap(),ipAddress,keyboard);
        }
      }
    }
    if (vm != null) {
      setEntityId(vm.getId());
    }
 else {
      throw new ServerApiException(BaseCmd.INTERNAL_ERROR,"String_Node_Str");
    }
  }
 catch (  InsufficientCapacityException ex) {
    s_logger.info(ex);
    s_logger.trace(ex);
    throw new ServerApiException(BaseCmd.INSUFFICIENT_CAPACITY_ERROR,ex.getMessage());
  }
catch (  ResourceUnavailableException ex) {
    s_logger.warn("String_Node_Str",ex);
    throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR,ex.getMessage());
  }
catch (  ConcurrentOperationException ex) {
    s_logger.warn("String_Node_Str",ex);
    throw new ServerApiException(BaseCmd.INTERNAL_ERROR,ex.getMessage());
  }
}