Github user mmiklavc commented on a diff in the pull request:
https://github.com/apache/incubator-metron/pull/119#discussion_r63114632
--- 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 --
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
---
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.
---