Program: 105807
Project: 105807
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();
  Long accountId=null;
  if (id == null) {
    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,userAccount);
        accountId=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 {
    AccessType accessType=AccessType.UseEntry;
    if (listAll || id != null) {
      accessType=AccessType.ListEntry;
    }
    domainIdRecursiveListProject.third(Project.ListProjectResourcesCriteria.SkipProjectResources);
    if (_querySelectors == null || _querySelectors.size() == 0)     return;
    QuerySelector qs=_querySelectors.get(0);
    boolean grantedAll=qs.isGrantedAll(caller,action,accessType);
    if (grantedAll) {
      if (accountId != null) {
        permittedAccounts.add(accountId);
        domainIdRecursiveListProject.second(false);
      }
 else       if (domainId != null) {
        permittedDomains.add(domainId);
      }
 else {
        domainIdRecursiveListProject.second(false);
      }
    }
 else {
      List<Long> grantedDomains=qs.getAuthorizedDomains(caller,action,accessType);
      List<Long> grantedAccounts=qs.getAuthorizedAccounts(caller,action,accessType);
      List<Long> grantedResources=qs.getAuthorizedResources(caller,action,accessType);
      if (accountId != null) {
        if (grantedAccounts.contains(accountId)) {
          permittedAccounts.add(accountId);
        }
 else {
          permittedResources.addAll(grantedResources);
        }
        domainIdRecursiveListProject.second(false);
      }
 else       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 {
        permittedDomains.addAll(grantedDomains);
        permittedAccounts.addAll(grantedAccounts);
        permittedResources.addAll(grantedResources);
        domainIdRecursiveListProject.second(false);
      }
      if (permittedDomains.isEmpty() && permittedAccounts.isEmpty() & permittedResources.isEmpty()) {
        permittedAccounts.add(-1L);
      }
    }
  }
}

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();
  Long accountId=null;
  if (id == null) {
    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,userAccount);
        accountId=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 {
    AccessType accessType=AccessType.UseEntry;
    if (listAll || id != null) {
      accessType=AccessType.ListEntry;
    }
    domainIdRecursiveListProject.third(Project.ListProjectResourcesCriteria.SkipProjectResources);
    if (_querySelectors == null || _querySelectors.size() == 0)     return;
    QuerySelector qs=_querySelectors.get(0);
    boolean grantedAll=qs.isGrantedAll(caller,action,accessType);
    if (grantedAll) {
      if (accountId != null) {
        permittedAccounts.add(accountId);
        domainIdRecursiveListProject.second(false);
      }
 else       if (domainId != null) {
        permittedDomains.add(domainId);
      }
 else {
        domainIdRecursiveListProject.second(false);
      }
    }
 else {
      List<Long> grantedDomains=qs.getAuthorizedDomains(caller,action,accessType);
      List<Long> grantedAccounts=qs.getAuthorizedAccounts(caller,action,accessType);
      List<Long> grantedResources=qs.getAuthorizedResources(caller,action,accessType);
      if (accountId != null) {
        if (grantedAccounts.contains(accountId)) {
          permittedAccounts.add(accountId);
        }
 else {
          permittedResources.addAll(grantedResources);
        }
        domainIdRecursiveListProject.second(false);
      }
 else       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 {
        permittedDomains.addAll(grantedDomains);
        permittedAccounts.addAll(grantedAccounts);
        permittedResources.addAll(grantedResources);
        domainIdRecursiveListProject.second(false);
      }
      if (permittedDomains.isEmpty() && permittedAccounts.isEmpty() && permittedResources.isEmpty()) {
        permittedAccounts.add(-1L);
      }
    }
  }
}