Program: 106549
Project: 106549
Buggy source:
@Override public List<RemoteAccessVpnVO> searchForRemoteAccessVpns(ListRemoteAccessVpnsCmd cmd){
  Account caller=UserContext.current().getCaller();
  Long ipAddressId=cmd.getPublicIpId();
  List<Long> permittedAccounts=new ArrayList<Long>();
  if (ipAddressId != null) {
    PublicIpAddress publicIp=_networkMgr.getPublicIpAddress(ipAddressId);
    if (publicIp == null) {
      throw new InvalidParameterValueException("String_Node_Str" + ipAddressId + "String_Node_Str");
    }
 else {
      Long ipAddrAcctId=publicIp.getAccountId();
      if (ipAddrAcctId == null) {
        throw new InvalidParameterValueException("String_Node_Str" + ipAddressId + "String_Node_Str");
      }
    }
    _accountMgr.checkAccess(caller,null,true,publicIp);
  }
  Ternary<Long,Boolean,ListProjectResourcesCriteria> domainIdRecursiveListProject=new Ternary<Long,Boolean,ListProjectResourcesCriteria>(cmd.getDomainId(),cmd.isRecursive(),null);
  _accountMgr.buildACLSearchParameters(caller,null,cmd.getAccountName(),cmd.getProjectId(),permittedAccounts,domainIdRecursiveListProject,cmd.listAll());
  Long domainId=domainIdRecursiveListProject.first();
  Boolean isRecursive=domainIdRecursiveListProject.second();
  ListProjectResourcesCriteria listProjectResourcesCriteria=domainIdRecursiveListProject.third();
  Filter filter=new Filter(RemoteAccessVpnVO.class,"String_Node_Str",false,cmd.getStartIndex(),cmd.getPageSizeVal());
  SearchBuilder<RemoteAccessVpnVO> sb=_remoteAccessVpnDao.createSearchBuilder();
  _accountMgr.buildACLSearchBuilder(sb,domainId,isRecursive,permittedAccounts,listProjectResourcesCriteria);
  sb.and("String_Node_Str",sb.entity().getServerAddressId(),Op.EQ);
  sb.and("String_Node_Str",sb.entity().getState(),Op.EQ);
  SearchCriteria<RemoteAccessVpnVO> sc=sb.create();
  _accountMgr.buildACLSearchCriteria(sc,domainId,isRecursive,permittedAccounts,listProjectResourcesCriteria);
  sc.setParameters("String_Node_Str",RemoteAccessVpn.State.Running);
  if (ipAddressId != null) {
    sc.setParameters("String_Node_Str",ipAddressId);
  }
  return _remoteAccessVpnDao.search(sc,filter);
}

Fixed version (ground truth):
@Override public List<RemoteAccessVpnVO> searchForRemoteAccessVpns(ListRemoteAccessVpnsCmd cmd){
  Account caller=UserContext.current().getCaller();
  Long ipAddressId=cmd.getPublicIpId();
  List<Long> permittedAccounts=new ArrayList<Long>();
  if (ipAddressId != null) {
    PublicIpAddress publicIp=_networkMgr.getPublicIpAddress(ipAddressId);
    if (publicIp == null) {
      throw new InvalidParameterValueException("String_Node_Str" + ipAddressId + "String_Node_Str");
    }
 else {
      Long ipAddrAcctId=publicIp.getAccountId();
      if (ipAddrAcctId == null) {
        throw new InvalidParameterValueException("String_Node_Str" + ipAddressId + "String_Node_Str");
      }
    }
    _accountMgr.checkAccess(caller,null,true,publicIp);
  }
  Ternary<Long,Boolean,ListProjectResourcesCriteria> domainIdRecursiveListProject=new Ternary<Long,Boolean,ListProjectResourcesCriteria>(cmd.getDomainId(),cmd.isRecursive(),null);
  _accountMgr.buildACLSearchParameters(caller,null,cmd.getAccountName(),cmd.getProjectId(),permittedAccounts,domainIdRecursiveListProject,cmd.listAll(),false);
  Long domainId=domainIdRecursiveListProject.first();
  Boolean isRecursive=domainIdRecursiveListProject.second();
  ListProjectResourcesCriteria listProjectResourcesCriteria=domainIdRecursiveListProject.third();
  Filter filter=new Filter(RemoteAccessVpnVO.class,"String_Node_Str",false,cmd.getStartIndex(),cmd.getPageSizeVal());
  SearchBuilder<RemoteAccessVpnVO> sb=_remoteAccessVpnDao.createSearchBuilder();
  _accountMgr.buildACLSearchBuilder(sb,domainId,isRecursive,permittedAccounts,listProjectResourcesCriteria);
  sb.and("String_Node_Str",sb.entity().getServerAddressId(),Op.EQ);
  sb.and("String_Node_Str",sb.entity().getState(),Op.EQ);
  SearchCriteria<RemoteAccessVpnVO> sc=sb.create();
  _accountMgr.buildACLSearchCriteria(sc,domainId,isRecursive,permittedAccounts,listProjectResourcesCriteria);
  sc.setParameters("String_Node_Str",RemoteAccessVpn.State.Running);
  if (ipAddressId != null) {
    sc.setParameters("String_Node_Str",ipAddressId);
  }
  return _remoteAccessVpnDao.search(sc,filter);
}