Github user ottobackwards commented on a diff in the pull request: https://github.com/apache/nifi/pull/2691#discussion_r187774740 --- Diff: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ExtractGrok.java --- @@ -179,17 +187,59 @@ public void onStopped() { bufferQueue.clear(); } + @Override + protected Collection<ValidationResult> customValidate(final ValidationContext validationContext) { + Collection<ValidationResult> problems = new ArrayList<>(); + + // validate the grok expression against configuration + boolean namedCaptures = false; + if (validationContext.getProperty(NAMED_CAPTURES_ONLY).isSet()) { + namedCaptures = validationContext.getProperty(NAMED_CAPTURES_ONLY).asBoolean(); + } + GrokCompiler grokCompiler = GrokCompiler.newInstance(); + String subject = GROK_EXPRESSION.getName(); + String input = validationContext.getProperty(GROK_EXPRESSION).getValue(); + if (validationContext.getProperty(GROK_PATTERN_FILE).isSet()) { + try (final InputStream in = new FileInputStream(new File(validationContext.getProperty(GROK_PATTERN_FILE).getValue())); + final Reader reader = new InputStreamReader(in)) { + grokCompiler.register(reader); + grok = grokCompiler.compile(input, namedCaptures); + } catch (IOException | GrokException | java.util.regex.PatternSyntaxException e) { + problems.add(new ValidationResult.Builder() + .subject(subject) --- End diff -- I needed to refactor this to be correct, sorry. Please check the new commit
---