[ https://issues.apache.org/jira/browse/NIFI-5170?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16473031#comment-16473031 ]
ASF GitHub Bot commented on NIFI-5170: -------------------------------------- Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2691#discussion_r187770374 --- 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 -- Why are you reusing the subject and input from the expression here? Is it because Grok uses the pattern to validate them? > Update Grok to 0.1.9 > -------------------- > > Key: NIFI-5170 > URL: https://issues.apache.org/jira/browse/NIFI-5170 > Project: Apache NiFi > Issue Type: New Feature > Reporter: Otto Fowler > Assignee: Otto Fowler > Priority: Major > > Grok 0.1.9 has been released, including work for empty capture support. > > https://github.com/thekrakken/java-grok#maven-repository -- This message was sent by Atlassian JIRA (v7.6.3#76005)