Program: 105930
Project: 105930
Buggy source:
@Override public void buildACLSearchParameters(Account caller,Long id,String accountName,Long projectId,List<Long> permittedDomains,List<Long> permittedAccounts,List<Long> permittedResources,Ternary<Long,Boolean,ListProjectResourcesCriteria> domainIdRecursiveListProject,boolean listAll,boolean forProjectInvitation,String action){
  Long domainId=domainIdRecursiveListProject.first();
  if (domainId != null) {
    Domain domain=_domainDao.findById(domainId);
    if (domain == null) {
      throw new InvalidParameterValueException("String_Node_Str" + domainId);
    }
    checkAccess(caller,domain);
  }
  if (accountName != null) {
    if (projectId != null) {
      throw new InvalidParameterValueException("String_Node_Str");
    }
    Account userAccount=null;
    Domain domain=null;
    if (domainId != null) {
      userAccount=_accountDao.findActiveAccount(accountName,domainId);
      domain=_domainDao.findById(domainId);
    }
 else {
      userAccount=_accountDao.findActiveAccount(accountName,caller.getDomainId());
      domain=_domainDao.findById(caller.getDomainId());
    }
    if (userAccount != null) {
      checkAccess(caller,null,false,userAccount);
      permittedAccounts.add(userAccount.getId());
    }
 else {
      throw new InvalidParameterValueException("String_Node_Str" + accountName + "String_Node_Str"+ domain.getUuid());
    }
  }
  if (projectId != null) {
    if (!forProjectInvitation) {
      if (projectId.longValue() == -1) {
        if (isNormalUser(caller.getId())) {
          permittedAccounts.addAll(_projectMgr.listPermittedProjectAccounts(caller.getId()));
        }
 else {
          domainIdRecursiveListProject.third(Project.ListProjectResourcesCriteria.ListProjectResourcesOnly);
        }
      }
 else {
        Project project=_projectMgr.getProject(projectId);
        if (project == null) {
          throw new InvalidParameterValueException("String_Node_Str" + projectId);
        }
        if (!_projectMgr.canAccessProjectAccount(caller,project.getProjectAccountId())) {
          throw new PermissionDeniedException("String_Node_Str" + caller + "String_Node_Str"+ projectId);
        }
        permittedAccounts.add(project.getProjectAccountId());
      }
    }
  }
 else {
    domainIdRecursiveListProject.third(Project.ListProjectResourcesCriteria.SkipProjectResources);
    if (_querySelectors == null || _querySelectors.size() == 0)     return;
    QuerySelector qs=_querySelectors.get(0);
    boolean grantedAll=qs.isGrantedAll(caller,action);
    if (grantedAll) {
      if (domainId != null) {
        permittedDomains.add(domainId);
      }
    }
 else {
      List<Long> grantedDomains=qs.getAuthorizedDomains(caller,action);
      List<Long> grantedAccounts=qs.getAuthorizedAccounts(caller,action);
      List<Long> grantedResources=qs.getAuthorizedResources(caller,action);
      if (domainId != null) {
        if (grantedDomains.contains(domainId)) {
          permittedDomains.add(domainId);
        }
 else {
          for (          Long acctId : grantedAccounts) {
            Account acct=_accountDao.findById(acctId);
            if (acct != null && acct.getDomainId() == domainId) {
              permittedAccounts.add(acctId);
            }
          }
          permittedResources.addAll(grantedResources);
        }
      }
 else       if (permittedAccounts.isEmpty()) {
        permittedDomains.addAll(grantedDomains);
        permittedAccounts.addAll(grantedAccounts);
        permittedResources.addAll(grantedResources);
      }
    }
  }
}

Fixed version (ground truth):
@Override public void buildACLSearchParameters(Account caller,Long id,String accountName,Long projectId,List<Long> permittedDomains,List<Long> permittedAccounts,List<Long> permittedResources,Ternary<Long,Boolean,ListProjectResourcesCriteria> domainIdRecursiveListProject,boolean listAll,boolean forProjectInvitation,String action){
  Long domainId=domainIdRecursiveListProject.first();
  if (domainId != null) {
    Domain domain=_domainDao.findById(domainId);
    if (domain == null) {
      throw new InvalidParameterValueException("String_Node_Str" + domainId);
    }
    checkAccess(caller,domain);
  }
  if (accountName != null) {
    if (projectId != null) {
      throw new InvalidParameterValueException("String_Node_Str");
    }
    Account userAccount=null;
    Domain domain=null;
    if (domainId != null) {
      userAccount=_accountDao.findActiveAccount(accountName,domainId);
      domain=_domainDao.findById(domainId);
    }
 else {
      userAccount=_accountDao.findActiveAccount(accountName,caller.getDomainId());
      domain=_domainDao.findById(caller.getDomainId());
    }
    if (userAccount != null) {
      checkAccess(caller,null,false,userAccount);
      permittedAccounts.add(userAccount.getId());
    }
 else {
      throw new InvalidParameterValueException("String_Node_Str" + accountName + "String_Node_Str"+ domain.getUuid());
    }
  }
  if (projectId != null) {
    if (!forProjectInvitation) {
      if (projectId.longValue() == -1) {
        if (isNormalUser(caller.getId())) {
          permittedAccounts.addAll(_projectMgr.listPermittedProjectAccounts(caller.getId()));
        }
 else {
          domainIdRecursiveListProject.third(Project.ListProjectResourcesCriteria.ListProjectResourcesOnly);
        }
      }
 else {
        Project project=_projectMgr.getProject(projectId);
        if (project == null) {
          throw new InvalidParameterValueException("String_Node_Str" + projectId);
        }
        if (!_projectMgr.canAccessProjectAccount(caller,project.getProjectAccountId())) {
          throw new PermissionDeniedException("String_Node_Str" + caller + "String_Node_Str"+ projectId);
        }
        permittedAccounts.add(project.getProjectAccountId());
      }
    }
  }
 else {
    domainIdRecursiveListProject.third(Project.ListProjectResourcesCriteria.SkipProjectResources);
    if (_querySelectors == null || _querySelectors.size() == 0)     return;
    QuerySelector qs=_querySelectors.get(0);
    boolean grantedAll=qs.isGrantedAll(caller,action);
    if (grantedAll) {
      if (domainId != null) {
        permittedDomains.add(domainId);
      }
    }
 else {
      List<Long> grantedDomains=qs.getAuthorizedDomains(caller,action);
      List<Long> grantedAccounts=qs.getAuthorizedAccounts(caller,action);
      List<Long> grantedResources=qs.getAuthorizedResources(caller,action);
      if (permittedAccounts.isEmpty() && domainId != null) {
        if (grantedDomains.contains(domainId)) {
          permittedDomains.add(domainId);
        }
 else {
          for (          Long acctId : grantedAccounts) {
            Account acct=_accountDao.findById(acctId);
            if (acct != null && acct.getDomainId() == domainId) {
              permittedAccounts.add(acctId);
            }
          }
          permittedResources.addAll(grantedResources);
        }
      }
 else       if (permittedAccounts.isEmpty()) {
        permittedDomains.addAll(grantedDomains);
        permittedAccounts.addAll(grantedAccounts);
        permittedResources.addAll(grantedResources);
      }
    }
  }
}