From 5c29cc9a28b8dde1937c29cd8cd06c2d9def70f8 Mon Sep 17 00:00:00 2001 From: Timothy Bish Date: Tue, 14 Jun 2016 19:05:27 -0400 Subject: [PATCH] ARTEMIS-568 Catch broken JMS selector expressions Enforce an EOF on the expression so the selector parser keeps going and catches the broken selector statement. --- artemis-selector/src/main/javacc/HyphenatedParser.jj | 2 +- artemis-selector/src/main/javacc/StrictParser.jj | 2 +- .../java/org/apache/activemq/artemis/selector/SelectorTest.java | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/artemis-selector/src/main/javacc/HyphenatedParser.jj b/artemis-selector/src/main/javacc/HyphenatedParser.jj index 8beb85a2c4..223e0886e4 100755 --- a/artemis-selector/src/main/javacc/HyphenatedParser.jj +++ b/artemis-selector/src/main/javacc/HyphenatedParser.jj @@ -142,7 +142,7 @@ BooleanExpression JmsSelector() : } { ( - left = orExpression() + left = orExpression() ) { return asBooleanExpression(left); diff --git a/artemis-selector/src/main/javacc/StrictParser.jj b/artemis-selector/src/main/javacc/StrictParser.jj index 2be6725f3c..0a318abc1b 100755 --- a/artemis-selector/src/main/javacc/StrictParser.jj +++ b/artemis-selector/src/main/javacc/StrictParser.jj @@ -142,7 +142,7 @@ BooleanExpression JmsSelector() : } { ( - left = orExpression() + left = orExpression() ) { return asBooleanExpression(left); diff --git a/artemis-selector/src/test/java/org/apache/activemq/artemis/selector/SelectorTest.java b/artemis-selector/src/test/java/org/apache/activemq/artemis/selector/SelectorTest.java index 223a0df6ab..d612db0eb5 100755 --- a/artemis-selector/src/test/java/org/apache/activemq/artemis/selector/SelectorTest.java +++ b/artemis-selector/src/test/java/org/apache/activemq/artemis/selector/SelectorTest.java @@ -470,6 +470,8 @@ public class SelectorTest { assertInvalidSelector(message, "3+5"); assertInvalidSelector(message, "True AND 3+5"); assertInvalidSelector(message, "=TEST 'test'"); + assertInvalidSelector(message, "prop1 = prop2 foo AND string = 'Test'"); + assertInvalidSelector(message, "a = 1 AMD b = 2"); } protected MockMessage createMessage() {