Program: 166430
Project: 166430
Buggy source:
boolean isValid(RangerPolicy policy,Action action,boolean isAdmin,List<ValidationFailureDetails> failures){
  if (LOG.isDebugEnabled()) {
    LOG.debug(String.format("String_Node_Str",policy,action,isAdmin,failures));
  }
  if (!(action == Action.CREATE || action == Action.UPDATE)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  boolean valid=true;
  if (policy == null) {
    String message="String_Node_Str";
    LOG.debug(message);
    failures.add(new ValidationFailureDetailsBuilder().field("String_Node_Str").isMissing().becauseOf(message).build());
    valid=false;
  }
 else {
    Long id=policy.getId();
    if (action == Action.UPDATE) {
      if (id == null) {
        String message="String_Node_Str";
        LOG.debug(message);
        failures.add(new ValidationFailureDetailsBuilder().field("String_Node_Str").isMissing().becauseOf(message).build());
        valid=false;
      }
 else       if (getPolicy(id) == null) {
        failures.add(new ValidationFailureDetailsBuilder().field("String_Node_Str").isSemanticallyIncorrect().becauseOf("String_Node_Str" + id + "String_Node_Str").build());
        valid=false;
      }
    }
    String policyName=policy.getName();
    String serviceName=policy.getService();
    if (StringUtils.isBlank(policyName)) {
      String message="String_Node_Str" + policyName + "String_Node_Str";
      LOG.debug(message);
      failures.add(new ValidationFailureDetailsBuilder().field("String_Node_Str").isMissing().becauseOf(message).build());
      valid=false;
    }
 else {
      List<RangerPolicy> policies=getPolicies(serviceName,policyName);
      if (CollectionUtils.isNotEmpty(policies)) {
        if (policies.size() > 1) {
          failures.add(new ValidationFailureDetailsBuilder().isAnInternalError().becauseOf("String_Node_Str" + policyName + "String_Node_Str").build());
          valid=false;
        }
 else         if (action == Action.CREATE) {
          failures.add(new ValidationFailureDetailsBuilder().field("String_Node_Str").isSemanticallyIncorrect().becauseOf("String_Node_Str" + policyName + "String_Node_Str"+ policies.iterator().next().getId()+ "String_Node_Str").build());
          valid=false;
        }
 else         if (policies.iterator().next().getId() != id) {
          failures.add(new ValidationFailureDetailsBuilder().field("String_Node_Str").isSemanticallyIncorrect().becauseOf("String_Node_Str" + policyName + "String_Node_Str"+ policies.iterator().next().getId()+ "String_Node_Str").build());
          valid=false;
        }
      }
    }
    RangerService service=null;
    if (StringUtils.isBlank(serviceName)) {
      failures.add(new ValidationFailureDetailsBuilder().field("String_Node_Str").isMissing().becauseOf("String_Node_Str").build());
      valid=false;
    }
 else {
      service=getService(serviceName);
      if (service == null) {
        failures.add(new ValidationFailureDetailsBuilder().field("String_Node_Str").isSemanticallyIncorrect().becauseOf("String_Node_Str").build());
        valid=false;
      }
    }
    List<RangerPolicyItem> policyItems=policy.getPolicyItems();
    boolean isAuditEnabled=getIsAuditEnabled(policy);
    RangerServiceDef serviceDef=null;
    String serviceDefName=null;
    if (CollectionUtils.isEmpty(policyItems) && !isAuditEnabled) {
      failures.add(new ValidationFailureDetailsBuilder().field("String_Node_Str").isMissing().becauseOf("String_Node_Str").build());
      valid=false;
    }
 else     if (service != null) {
      serviceDefName=service.getType();
      serviceDef=getServiceDef(serviceDefName);
      if (serviceDef == null) {
        failures.add(new ValidationFailureDetailsBuilder().field("String_Node_Str").isAnInternalError().becauseOf("String_Node_Str").build());
        valid=false;
      }
 else {
        valid=isValidPolicyItems(policyItems,failures,serviceDef) && valid;
      }
    }
    valid=isValidResources(policy,failures,action,isAdmin,serviceDef,serviceName) && valid;
  }
  if (LOG.isDebugEnabled()) {
    LOG.debug(String.format("String_Node_Str",policy,action,isAdmin,failures,valid));
  }
  return valid;
}

Fixed version (ground truth):
boolean isValid(RangerPolicy policy,Action action,boolean isAdmin,List<ValidationFailureDetails> failures){
  if (LOG.isDebugEnabled()) {
    LOG.debug(String.format("String_Node_Str",policy,action,isAdmin,failures));
  }
  if (!(action == Action.CREATE || action == Action.UPDATE)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  boolean valid=true;
  if (policy == null) {
    String message="String_Node_Str";
    LOG.debug(message);
    failures.add(new ValidationFailureDetailsBuilder().field("String_Node_Str").isMissing().becauseOf(message).build());
    valid=false;
  }
 else {
    Long id=policy.getId();
    if (action == Action.UPDATE) {
      if (id == null) {
        String message="String_Node_Str";
        LOG.debug(message);
        failures.add(new ValidationFailureDetailsBuilder().field("String_Node_Str").isMissing().becauseOf(message).build());
        valid=false;
      }
 else       if (getPolicy(id) == null) {
        failures.add(new ValidationFailureDetailsBuilder().field("String_Node_Str").isSemanticallyIncorrect().becauseOf("String_Node_Str" + id + "String_Node_Str").build());
        valid=false;
      }
    }
    String policyName=policy.getName();
    String serviceName=policy.getService();
    if (StringUtils.isBlank(policyName)) {
      String message="String_Node_Str" + policyName + "String_Node_Str";
      LOG.debug(message);
      failures.add(new ValidationFailureDetailsBuilder().field("String_Node_Str").isMissing().becauseOf(message).build());
      valid=false;
    }
 else {
      List<RangerPolicy> policies=getPolicies(serviceName,policyName);
      if (CollectionUtils.isNotEmpty(policies)) {
        if (policies.size() > 1) {
          failures.add(new ValidationFailureDetailsBuilder().isAnInternalError().becauseOf("String_Node_Str" + policyName + "String_Node_Str").build());
          valid=false;
        }
 else         if (action == Action.CREATE) {
          failures.add(new ValidationFailureDetailsBuilder().field("String_Node_Str").isSemanticallyIncorrect().becauseOf("String_Node_Str" + policyName + "String_Node_Str"+ policies.iterator().next().getId()+ "String_Node_Str").build());
          valid=false;
        }
 else         if (!policies.iterator().next().getId().equals(id)) {
          failures.add(new ValidationFailureDetailsBuilder().field("String_Node_Str").isSemanticallyIncorrect().becauseOf("String_Node_Str" + policyName + "String_Node_Str"+ policies.iterator().next().getId()+ "String_Node_Str").build());
          valid=false;
        }
      }
    }
    RangerService service=null;
    if (StringUtils.isBlank(serviceName)) {
      failures.add(new ValidationFailureDetailsBuilder().field("String_Node_Str").isMissing().becauseOf("String_Node_Str").build());
      valid=false;
    }
 else {
      service=getService(serviceName);
      if (service == null) {
        failures.add(new ValidationFailureDetailsBuilder().field("String_Node_Str").isSemanticallyIncorrect().becauseOf("String_Node_Str").build());
        valid=false;
      }
    }
    List<RangerPolicyItem> policyItems=policy.getPolicyItems();
    boolean isAuditEnabled=getIsAuditEnabled(policy);
    RangerServiceDef serviceDef=null;
    String serviceDefName=null;
    if (CollectionUtils.isEmpty(policyItems) && !isAuditEnabled) {
      failures.add(new ValidationFailureDetailsBuilder().field("String_Node_Str").isMissing().becauseOf("String_Node_Str").build());
      valid=false;
    }
 else     if (service != null) {
      serviceDefName=service.getType();
      serviceDef=getServiceDef(serviceDefName);
      if (serviceDef == null) {
        failures.add(new ValidationFailureDetailsBuilder().field("String_Node_Str").isAnInternalError().becauseOf("String_Node_Str").build());
        valid=false;
      }
 else {
        valid=isValidPolicyItems(policyItems,failures,serviceDef) && valid;
      }
    }
    valid=isValidResources(policy,failures,action,isAdmin,serviceDef,serviceName) && valid;
  }
  if (LOG.isDebugEnabled()) {
    LOG.debug(String.format("String_Node_Str",policy,action,isAdmin,failures,valid));
  }
  return valid;
}