Program: 106070
Project: 106070
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 (id != null) {
    permittedResources.add(id);
    return;
  }
  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);
    List<Long> grantedDomains=_aclService.getGrantedDomains(caller.getId(),action);
    List<Long> grantedAccounts=_aclService.getGrantedAccounts(caller.getId(),action);
    List<Long> grantedResources=_aclService.getGrantedResources(caller.getId(),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 (id != null) {
    permittedResources.add(id);
    return;
  }
  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);
    boolean grantedAll=_aclService.isGrantedAll(caller.getId(),action);
    if (grantedAll) {
      if (domainId != null) {
        permittedDomains.add(domainId);
      }
    }
 else {
      List<Long> grantedDomains=_aclService.getGrantedDomains(caller.getId(),action);
      List<Long> grantedAccounts=_aclService.getGrantedAccounts(caller.getId(),action);
      List<Long> grantedResources=_aclService.getGrantedResources(caller.getId(),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);
      }
    }
  }
}