Github user cestella commented on a diff in the pull request:
https://github.com/apache/incubator-metron/pull/119#discussion_r63114735
--- Diff:
metron-platform/metron-common/src/main/java/org/apache/metron/common/query/PredicateProcessor.java
---
@@ -18,12 +18,20 @@
package org.apache.metron.common.query;
-import org.antlr.v4.runtime.*;
-import org.apache.metron.common.query.generated.*;
+import org.antlr.v4.runtime.ANTLRInputStream;
+import org.antlr.v4.runtime.CommonTokenStream;
+import org.antlr.v4.runtime.TokenStream;
+import org.apache.metron.common.query.generated.PredicateLexer;
+import org.apache.metron.common.query.generated.PredicateParser;
+
+import static org.apache.commons.lang3.StringUtils.isEmpty;
public class PredicateProcessor {
public boolean parse(String rule, VariableResolver resolver) {
+ if (isEmpty(rule)) {
--- End diff --
I vote for 2
On Thu, May 12, 2016 at 19:36 Michael Miklavcic <[email protected]>
wrote:
> In
>
metron-platform/metron-common/src/main/java/org/apache/metron/common/query/PredicateProcessor.java
> <https://github.com/apache/incubator-metron/pull/119#discussion_r63114632>
> :
>
> >
> >
> > public class PredicateProcessor {
> > public boolean parse(String rule, VariableResolver resolver) {
> > + if (isEmpty(rule)) {
>
> To clarify, I've added the following test cases:
>
> Assert.assertTrue(run(null, v -> variableMap.get(v)));
> Assert.assertTrue(run("", v -> variableMap.get(v)));
> Assert.assertTrue(run(" ", v -> variableMap.get(v)));
>
> The null results in an NPE from ANTLR.
> Either we:
> 1. Add an else to return true
> 2. Do this(my vote): if (rule == null || isEmpty(rule.trim())) { return
> true; }
> 3. Or throw a new exception for the parser
>
> â
> You are receiving this because you were mentioned.
> Reply to this email directly or view it on GitHub
>
<https://github.com/apache/incubator-metron/pull/119/files/b3af68484718a66393f4b0417bc525c462afed5d#r63114632>
>
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---