Program: 106562
Project: 106562
Buggy source:
@Override public void buildACLSearchParameters(Account caller,Long id,String accountName,Long projectId,List<Long> permittedAccounts,Ternary<Long,Boolean,ListProjectResourcesCriteria> domainIdRecursiveListProject,boolean listAll){
  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;
    if (domainId != null) {
      userAccount=_accountDao.findActiveAccount(accountName,domainId);
    }
 else {
      userAccount=_accountDao.findActiveAccount(accountName,caller.getDomainId());
    }
    if (userAccount != null) {
      permittedAccounts.add(userAccount.getId());
    }
 else {
      throw new InvalidParameterValueException("String_Node_Str" + accountName + "String_Node_Str"+ domainId);
    }
  }
  if (projectId != null) {
    if (projectId == -1) {
      if (caller.getType() == Account.ACCOUNT_TYPE_NORMAL) {
        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 {
    if (id == null) {
      domainIdRecursiveListProject.third(Project.ListProjectResourcesCriteria.SkipProjectResources);
    }
    if (permittedAccounts.isEmpty() && domainId == null) {
      if (caller.getType() == Account.ACCOUNT_TYPE_NORMAL) {
        permittedAccounts.add(caller.getId());
      }
 else       if (!listAll) {
        if (id == null) {
          permittedAccounts.add(caller.getId());
        }
 else         if (caller.getType() != Account.ACCOUNT_TYPE_ADMIN) {
          domainIdRecursiveListProject.first(caller.getDomainId());
          domainIdRecursiveListProject.second(true);
        }
      }
 else       if (domainId == null) {
        if (caller.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) {
          domainIdRecursiveListProject.first(caller.getDomainId());
          domainIdRecursiveListProject.second(true);
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override public void buildACLSearchParameters(Account caller,Long id,String accountName,Long projectId,List<Long> permittedAccounts,Ternary<Long,Boolean,ListProjectResourcesCriteria> domainIdRecursiveListProject,boolean listAll,boolean forProjectInvitation){
  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;
    if (domainId != null) {
      userAccount=_accountDao.findActiveAccount(accountName,domainId);
    }
 else {
      userAccount=_accountDao.findActiveAccount(accountName,caller.getDomainId());
    }
    if (userAccount != null) {
      permittedAccounts.add(userAccount.getId());
    }
 else {
      throw new InvalidParameterValueException("String_Node_Str" + accountName + "String_Node_Str"+ domainId);
    }
  }
  if (projectId != null) {
    if (!forProjectInvitation) {
      if (projectId == -1) {
        if (caller.getType() == Account.ACCOUNT_TYPE_NORMAL) {
          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 {
    if (id == null) {
      domainIdRecursiveListProject.third(Project.ListProjectResourcesCriteria.SkipProjectResources);
    }
    if (permittedAccounts.isEmpty() && domainId == null) {
      if (caller.getType() == Account.ACCOUNT_TYPE_NORMAL) {
        permittedAccounts.add(caller.getId());
      }
 else       if (!listAll) {
        if (id == null) {
          permittedAccounts.add(caller.getId());
        }
 else         if (caller.getType() != Account.ACCOUNT_TYPE_ADMIN) {
          domainIdRecursiveListProject.first(caller.getDomainId());
          domainIdRecursiveListProject.second(true);
        }
      }
 else       if (domainId == null) {
        if (caller.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) {
          domainIdRecursiveListProject.first(caller.getDomainId());
          domainIdRecursiveListProject.second(true);
        }
      }
    }
  }
}