Program: 42872
Project: 42872
Buggy source:
private void validate(RsProtectParams params){
  if (params.getResources() == null || params.getResources().isEmpty()) {
    throw new ErrorResponseException(ErrorResponseCode.NO_UMA_RESOURCES_TO_PROTECT);
  }
  if (!org.xdi.oxd.rs.protect.ResourceValidator.isHttpMethodUniqueInPath(params.getResources())) {
    throw new ErrorResponseException(ErrorResponseCode.UMA_HTTP_METHOD_NOT_UNIQUE);
  }
  if (params.getResources() != null) {
    for (    RsResource resource : params.getResources()) {
      if (resource.getConditions() != null) {
        for (        Condition condition : resource.getConditions()) {
          if (condition.getScopeExpression() != null) {
            String json=condition.getScopeExpression().toString();
            if (StringUtils.isNotBlank(json)) {
              boolean nodeValid=JsonLogicNodeParser.isNodeValid(json);
              LOG.trace("String_Node_Str" + nodeValid + "String_Node_Str"+ json);
              if (!nodeValid) {
                throw new ErrorResponseException(ErrorResponseCode.UMA_FAILED_TO_VALIDATE_SCOPE_EXPRESSION);
              }
            }
          }
        }
      }
    }
  }
  List<UmaResource> existingUmaResources=getRp().getUmaProtectedResources();
  if (existingUmaResources != null && !existingUmaResources.isEmpty()) {
    if (params.getOverwrite() == null || !params.getOverwrite()) {
      throw new ErrorResponseException(ErrorResponseCode.UMA_PROTECTION_FAILED_BECAUSE_RESOURCES_ALREADY_EXISTS);
    }
 else {
      UmaMetadata discovery=getDiscoveryService().getUmaDiscoveryByOxdId(params.getOxdId());
      UmaResourceService resourceService=UmaClientFactory.instance().createResourceService(discovery,getHttpService().getClientExecutor());
      String pat=getUmaTokenService().getPat(params.getOxdId()).getToken();
      for (      UmaResource resource : existingUmaResources) {
        LOG.trace("String_Node_Str" + resource.getId() + "String_Node_Str");
        resourceService.deleteResource("String_Node_Str" + pat,resource.getId());
        LOG.trace("String_Node_Str" + resource.getId() + "String_Node_Str");
      }
    }
  }
}

Fixed version (ground truth):
private void validate(RsProtectParams params){
  if (params.getResources() == null || params.getResources().isEmpty()) {
    throw new ErrorResponseException(ErrorResponseCode.NO_UMA_RESOURCES_TO_PROTECT);
  }
  if (!org.xdi.oxd.rs.protect.ResourceValidator.isHttpMethodUniqueInPath(params.getResources())) {
    throw new ErrorResponseException(ErrorResponseCode.UMA_HTTP_METHOD_NOT_UNIQUE);
  }
  if (params.getResources() != null) {
    for (    RsResource resource : params.getResources()) {
      if (resource.getConditions() != null) {
        for (        Condition condition : resource.getConditions()) {
          if (condition.getScopeExpression() != null) {
            String json=condition.getScopeExpression().toString();
            if (StringUtils.isNotBlank(json)) {
              boolean nodeValid=JsonLogicNodeParser.isNodeValid(json);
              LOG.trace("String_Node_Str" + nodeValid + "String_Node_Str"+ json);
              if (!nodeValid) {
                throw new ErrorResponseException(ErrorResponseCode.UMA_FAILED_TO_VALIDATE_SCOPE_EXPRESSION);
              }
            }
          }
        }
      }
    }
  }
  Rp rp=getRp();
  List<UmaResource> existingUmaResources=rp.getUmaProtectedResources();
  if (existingUmaResources != null && !existingUmaResources.isEmpty()) {
    if (params.getOverwrite() == null || !params.getOverwrite()) {
      throw new ErrorResponseException(ErrorResponseCode.UMA_PROTECTION_FAILED_BECAUSE_RESOURCES_ALREADY_EXISTS);
    }
 else {
      UmaMetadata discovery=getDiscoveryService().getUmaDiscoveryByOxdId(params.getOxdId());
      UmaResourceService resourceService=UmaClientFactory.instance().createResourceService(discovery,getHttpService().getClientExecutor());
      String pat=getUmaTokenService().getPat(params.getOxdId()).getToken();
      for (      UmaResource resource : existingUmaResources) {
        LOG.trace("String_Node_Str" + resource.getId() + "String_Node_Str");
        resourceService.deleteResource("String_Node_Str" + pat,resource.getId());
        LOG.trace("String_Node_Str" + resource.getId() + "String_Node_Str");
      }
      rp.getUmaProtectedResources().clear();
      getRpService().updateSilently(rp);
    }
  }
}