Program: 105094
Project: 105094
Buggy source:
private Pair<Long,Long> getAccountDomain(long resourceId,ResourceObjectType resourceType){
  Class<?> clazz=s_typeMap.get(resourceType);
  Object entity=_entityMgr.findById(clazz,resourceId);
  Long accountId=null;
  Long domainId=null;
  if (resourceType == ResourceObjectType.SecurityGroupRule) {
    SecurityGroupRuleVO rule=(SecurityGroupRuleVO)entity;
    Object SecurityGroup=_entityMgr.findById(s_typeMap.get(ResourceObjectType.SecurityGroup),rule.getSecurityGroupId());
    accountId=((SecurityGroupVO)SecurityGroup).getAccountId();
    domainId=((SecurityGroupVO)SecurityGroup).getDomainId();
  }
  if (resourceType == ResourceObjectType.NetworkACL) {
    NetworkACLItemVO aclItem=(NetworkACLItemVO)entity;
    Object networkACL=_entityMgr.findById(s_typeMap.get(ResourceObjectType.NetworkACLList),aclItem.getAclId());
    Long vpcId=((NetworkACLVO)networkACL).getVpcId();
    if (vpcId != null && vpcId != 0) {
      Object vpc=_entityMgr.findById(s_typeMap.get(ResourceObjectType.Vpc),vpcId);
      accountId=((VpcVO)vpc).getAccountId();
      domainId=((VpcVO)vpc).getDomainId();
    }
  }
  if (entity instanceof OwnedBy) {
    accountId=((OwnedBy)entity).getAccountId();
  }
  if (entity instanceof PartOf) {
    domainId=((PartOf)entity).getDomainId();
  }
  if (accountId == null) {
    accountId=Account.ACCOUNT_ID_SYSTEM;
  }
  if ((domainId == null) || ((accountId != null) && (domainId.longValue() == -1))) {
    domainId=_accountDao.getDomainIdForGivenAccountId(accountId);
  }
  return new Pair<Long,Long>(accountId,domainId);
}

Fixed version (ground truth):
private Pair<Long,Long> getAccountDomain(long resourceId,ResourceObjectType resourceType){
  Class<?> clazz=s_typeMap.get(resourceType);
  Object entity=_entityMgr.findById(clazz,resourceId);
  Long accountId=null;
  Long domainId=null;
  if (resourceType == ResourceObjectType.SecurityGroupRule) {
    SecurityGroupRuleVO rule=(SecurityGroupRuleVO)entity;
    Object SecurityGroup=_entityMgr.findById(s_typeMap.get(ResourceObjectType.SecurityGroup),rule.getSecurityGroupId());
    accountId=((SecurityGroupVO)SecurityGroup).getAccountId();
    domainId=((SecurityGroupVO)SecurityGroup).getDomainId();
  }
  if (resourceType == ResourceObjectType.Account) {
    AccountVO account=(AccountVO)entity;
    accountId=account.getId();
    domainId=account.getDomainId();
  }
  if (resourceType == ResourceObjectType.NetworkACL) {
    NetworkACLItemVO aclItem=(NetworkACLItemVO)entity;
    Object networkACL=_entityMgr.findById(s_typeMap.get(ResourceObjectType.NetworkACLList),aclItem.getAclId());
    Long vpcId=((NetworkACLVO)networkACL).getVpcId();
    if (vpcId != null && vpcId != 0) {
      Object vpc=_entityMgr.findById(s_typeMap.get(ResourceObjectType.Vpc),vpcId);
      accountId=((VpcVO)vpc).getAccountId();
      domainId=((VpcVO)vpc).getDomainId();
    }
  }
  if (entity instanceof OwnedBy) {
    accountId=((OwnedBy)entity).getAccountId();
  }
  if (entity instanceof PartOf) {
    domainId=((PartOf)entity).getDomainId();
  }
  if (accountId == null) {
    accountId=Account.ACCOUNT_ID_SYSTEM;
  }
  if ((domainId == null) || ((accountId != null) && (domainId.longValue() == -1))) {
    domainId=_accountDao.getDomainIdForGivenAccountId(accountId);
  }
  return new Pair<>(accountId,domainId);
}