Program: 106333
Project: 106333
Buggy source:
@Override public UserVm createAdvancedSecurityGroupVirtualMachine(DataCenter zone,ServiceOffering serviceOffering,VirtualMachineTemplate template,List<Long> networkIdList,List<Long> securityGroupIdList,Account owner,String hostName,String displayName,Long diskOfferingId,Long diskSize,String group,HypervisorType hypervisor,String userData,String sshKeyPair,Map<Long,IpAddresses> requestedIps,IpAddresses defaultIps,String keyboard) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException {
}

Fixed version (ground truth):
@Override public UserVm createAdvancedSecurityGroupVirtualMachine(DataCenter zone,ServiceOffering serviceOffering,VirtualMachineTemplate template,List<Long> networkIdList,List<Long> securityGroupIdList,Account owner,String hostName,String displayName,Long diskOfferingId,Long diskSize,String group,HypervisorType hypervisor,String userData,String sshKeyPair,Map<Long,IpAddresses> requestedIps,IpAddresses defaultIps,String keyboard) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException {
  Account caller=UserContext.current().getCaller();
  List<NetworkVO> networkList=new ArrayList<NetworkVO>();
  boolean isSecurityGroupEnabledNetworkUsed=false;
  boolean isVmWare=(template.getHypervisorType() == HypervisorType.VMware || (hypervisor != null && hypervisor == HypervisorType.VMware));
  _accountMgr.checkAccess(caller,null,true,owner);
  if (networkIdList == null || networkIdList.isEmpty()) {
    Network networkWithSecurityGroup=_networkModel.getNetworkWithSecurityGroupEnabled(zone.getId());
    if (networkWithSecurityGroup == null) {
      throw new InvalidParameterValueException("String_Node_Str" + zone.getId());
    }
    networkList.add(_networkDao.findById(networkWithSecurityGroup.getId()));
    isSecurityGroupEnabledNetworkUsed=true;
  }
 else   if (securityGroupIdList != null && !securityGroupIdList.isEmpty()) {
    if (isVmWare) {
      throw new InvalidParameterValueException("String_Node_Str");
    }
    if (networkIdList.size() > 1) {
      throw new InvalidParameterValueException("String_Node_Str");
    }
    NetworkVO network=_networkDao.findById(networkIdList.get(0).longValue());
    if (network == null) {
      throw new InvalidParameterValueException("String_Node_Str" + networkIdList.get(0).longValue());
    }
    if (!_networkModel.isSecurityGroupSupportedInNetwork(network)) {
      throw new InvalidParameterValueException("String_Node_Str" + network.getId());
    }
    networkList.add(network);
    isSecurityGroupEnabledNetworkUsed=true;
  }
 else {
    for (    Long networkId : networkIdList) {
      NetworkVO network=_networkDao.findById(networkId);
      if (network == null) {
        throw new InvalidParameterValueException("String_Node_Str" + networkIdList.get(0).longValue());
      }
      boolean isSecurityGroupEnabled=_networkModel.isSecurityGroupSupportedInNetwork(network);
      if (isSecurityGroupEnabled) {
        if (networkIdList.size() > 1) {
          throw new InvalidParameterValueException("String_Node_Str" + "String_Node_Str");
        }
        isSecurityGroupEnabledNetworkUsed=true;
      }
      if (!(network.getTrafficType() == TrafficType.Guest && network.getGuestType() == Network.GuestType.Shared)) {
        throw new InvalidParameterValueException("String_Node_Str" + "String_Node_Str");
      }
      if (network.getAclType() == ACLType.Account) {
        _accountMgr.checkAccess(caller,AccessType.UseNetwork,false,network);
      }
      networkList.add(network);
    }
  }
  if (isSecurityGroupEnabledNetworkUsed && !isVmWare && _networkModel.canAddDefaultSecurityGroup()) {
    if (securityGroupIdList == null || securityGroupIdList.isEmpty()) {
      if (securityGroupIdList == null) {
        securityGroupIdList=new ArrayList<Long>();
      }
      SecurityGroup defaultGroup=_securityGroupMgr.getDefaultSecurityGroup(owner.getId());
      if (defaultGroup != null) {
        securityGroupIdList.add(defaultGroup.getId());
      }
 else {
        if (s_logger.isDebugEnabled()) {
          s_logger.debug("String_Node_Str" + owner + "String_Node_Str");
        }
        defaultGroup=_securityGroupMgr.createSecurityGroup(SecurityGroupManager.DEFAULT_GROUP_NAME,SecurityGroupManager.DEFAULT_GROUP_DESCRIPTION,owner.getDomainId(),owner.getId(),owner.getAccountName());
        securityGroupIdList.add(defaultGroup.getId());
      }
    }
  }
  return createVirtualMachine(zone,serviceOffering,template,hostName,displayName,owner,diskOfferingId,diskSize,networkList,securityGroupIdList,group,userData,sshKeyPair,hypervisor,caller,requestedIps,defaultIps,keyboard);
}