basic-lib/src/main/java/com/streamsets/pipeline/stage/processor/fieldvaluereplacer/FieldValueReplacerProcessor.java
private List<String> getFieldsToNull(List<NullReplacerConditionalConfig> nullReplacerConditionalConfigs, Set<String> fieldsThatDoNotExist, Set<String> fieldPaths, Record record) throws OnRecordErrorException {
    //Gather in this all fields to null
    List<String> fieldsToNull = new ArrayList<>();

    for (NullReplacerConditionalConfig nullReplacerConditionalConfig : nullReplacerConditionalConfigs) {
      List<String> fieldNamesToNull = nullReplacerConditionalConfig.fieldsToNull;
      //Gather fieldsPathsToNull for this nullReplacerConditionalConfig
      List<String> fieldPathsToNull = new ArrayList<>();
      //Gather existing paths for each nullReplacerConditionalConfig
      //And if field does not exist gather them in fieldsThatDoNotExist
      for (String fieldNameToNull : fieldNamesToNull) {
        try {
          final List<String> matchingPaths = FieldPathExpressionUtil.evaluateMatchingFieldPaths(
              fieldNameToNull,
              fieldPathEval,
              fieldPathVars,
              record,
              fieldPaths
          );
          if (matchingPaths.isEmpty()) {
            // FieldPathExpressionUtil.evaluateMatchingFieldPaths does NOT return the supplied param in its result
            // regardless, like FieldRegexUtil#getMatchingFieldPaths did, so we add manually here
            fieldsThatDoNotExist.add(fieldNameToNull);
          } else {
            for (String matchingField : matchingPaths) {
              if (record.has(matchingField)) {
                fieldPathsToNull.add(matchingField);
              } else {
                fieldsThatDoNotExist.add(matchingField);
              }
            }
          }
        } catch (ELEvalException e) {
          LOG.error("Error evaluating condition: " + nullReplacerConditionalConfig.condition, e);
          throw new OnRecordErrorException(record, Errors.VALUE_REPLACER_07, fieldNameToNull, e.toString(), e);
        }
      }
      //Now evaluate the condition in nullReplacerConditionalConfig
      //If it empty or condition evaluates to true, add all the gathered fields in fieldsPathsToNull
      // for this nullReplacerConditionalConfig to fieldsToNull
      try {
        boolean evaluatedCondition = true;
        //If it is empty we assume it is true.
        if (!StringUtils.isEmpty(nullReplacerConditionalConfig.condition)) {
          evaluatedCondition = nullConditionELEval.eval(nullConditionELVars, nullReplacerConditionalConfig.condition, Boolean.class);
        }
        if (evaluatedCondition) {
          fieldsToNull.addAll(fieldPathsToNull);
        }
      } catch (ELEvalException e) {
        LOG.error("Error evaluating condition: " + nullReplacerConditionalConfig.condition, e);
        throw new OnRecordErrorException(record, Errors.VALUE_REPLACER_06, nullReplacerConditionalConfig.condition, e.toString());
      }
    }
    return fieldsToNull;
  }
private List<String> getFieldsToNull(List<NullReplacerConditionalConfig> nullReplacerConditionalConfigs, Set<String> fieldsThatDoNotExist, Set<String> fieldPaths, Record record) throws OnRecordErrorException {
    //Gather in this all fields to null
    List<String> fieldsToNull = new ArrayList<>();

    for (NullReplacerConditionalConfig nullReplacerConditionalConfig : nullReplacerConditionalConfigs) {
      List<String> fieldNamesToNull = nullReplacerConditionalConfig.fieldsToNull;
      //Gather fieldsPathsToNull for this nullReplacerConditionalConfig
      List<String> fieldPathsToNull = new ArrayList<>();
      //Gather existing paths for each nullReplacerConditionalConfig
      //And if field does not exist gather them in fieldsThatDoNotExist
      for (String fieldNameToNull : fieldNamesToNull) {
        try {
          final List<String> matchingPaths = FieldPathExpressionUtil.evaluateMatchingFieldPaths(
              fieldNameToNull,
              fieldPathEval,
              fieldPathVars,
              record,
              fieldPaths
          );
          if (matchingPaths.isEmpty()) {
            // FieldPathExpressionUtil.evaluateMatchingFieldPaths does NOT return the supplied param in its result
            // regardless, like FieldRegexUtil#getMatchingFieldPaths did, so we add manually here
            fieldsThatDoNotExist.add(fieldNameToNull);
          } else {
            for (String matchingField : matchingPaths) {
              if (record.has(matchingField)) {
                fieldPathsToNull.add(matchingField);
              } else {
                fieldsThatDoNotExist.add(matchingField);
              }
            }
          }
        } catch (ELEvalException e) {
          LOG.error("Error evaluating condition: " + nullReplacerConditionalConfig.condition, e);
          throw new OnRecordErrorException(record, Errors.VALUE_REPLACER_07, fieldNameToNull, e.toString(), e);
        }
      }
      //Now evaluate the condition in nullReplacerConditionalConfig
      //If it empty or condition evaluates to true, add all the gathered fields in fieldsPathsToNull
      // for this nullReplacerConditionalConfig to fieldsToNull
      try {
        boolean evaluatedCondition = true;
        //If it is empty we assume it is true.
        if (!StringUtils.isEmpty(nullReplacerConditionalConfig.condition)) {
          evaluatedCondition = nullConditionELEval.eval(nullConditionELVars, nullReplacerConditionalConfig.condition, Boolean.class);
        }
        if (evaluatedCondition) {
          fieldsToNull.addAll(fieldPathsToNull);
        }
      } catch (ELEvalException e) {
        LOG.error("Error evaluating condition: " + nullReplacerConditionalConfig.condition, e);
        throw new OnRecordErrorException(record, Errors.VALUE_REPLACER_06, nullReplacerConditionalConfig.condition, e.toString());
      }
    }
    return fieldsToNull;
  }
private List < String > getFieldsToNull ( List < NullReplacerConditionalConfig > nullReplacerConditionalConfigs , Set < String > fieldsThatDoNotExist , Set < String > fieldPaths , Record record ) throws OnRecordErrorException { //Gather in this all fields to null List < String > fieldsToNull = new ArrayList <> ( ) ; for ( NullReplacerConditionalConfig nullReplacerConditionalConfig : nullReplacerConditionalConfigs ) { List < String > fieldNamesToNull = nullReplacerConditionalConfig . fieldsToNull ; //Gather fieldsPathsToNull for this nullReplacerConditionalConfig List < String > fieldPathsToNull = new ArrayList <> ( ) ; //Gather existing paths for each nullReplacerConditionalConfig //And if field does not exist gather them in fieldsThatDoNotExist for ( String fieldNameToNull : fieldNamesToNull ) { try { final List < String > matchingPaths = FieldPathExpressionUtil . evaluateMatchingFieldPaths ( fieldNameToNull , fieldPathEval , fieldPathVars , record , fieldPaths ) ; if ( matchingPaths . isEmpty ( ) ) { // FieldPathExpressionUtil.evaluateMatchingFieldPaths does NOT return the supplied param in its result // regardless, like FieldRegexUtil#getMatchingFieldPaths did, so we add manually here fieldsThatDoNotExist . add ( fieldNameToNull ) ; } else { for ( String matchingField : matchingPaths ) { if ( record . has ( matchingField ) ) { fieldPathsToNull . add ( matchingField ) ; } else { fieldsThatDoNotExist . add ( matchingField ) ; } } } } catch ( ELEvalException e ) { LOG . error ( "Error evaluating condition: " + nullReplacerConditionalConfig . condition , e ) ; throw new OnRecordErrorException ( record , Errors . VALUE_REPLACER_07 , fieldNameToNull , e . toString ( ) , e ) ; } } //Now evaluate the condition in nullReplacerConditionalConfig //If it empty or condition evaluates to true, add all the gathered fields in fieldsPathsToNull // for this nullReplacerConditionalConfig to fieldsToNull try { boolean evaluatedCondition = true ; //If it is empty we assume it is true. if ( ! StringUtils . isEmpty ( nullReplacerConditionalConfig . condition ) ) { evaluatedCondition = nullConditionELEval . eval ( nullConditionELVars , nullReplacerConditionalConfig . condition , Boolean . class ) ; } if ( evaluatedCondition ) { fieldsToNull . addAll ( fieldPathsToNull ) ; } } catch ( ELEvalException e ) { LOG . error ( "Error evaluating condition: " + nullReplacerConditionalConfig . condition , e ) ; throw new OnRecordErrorException ( record , Errors . VALUE_REPLACER_06 , nullReplacerConditionalConfig . condition , e . toString ( ) ) ; } } return fieldsToNull ; }
should be replaced by null.
should be replaced by null .