[ https://issues.apache.org/jira/browse/QPID-8674?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17904749#comment-17904749 ]
Daniil Kirilyuk commented on QPID-8674: --------------------------------------- Hello Robbie, It seems, that the original Qpid Broker-J JMS selector parser grammar fails with the NOT operator precedence in cases when it isn't part of NOT BETWEEN, NOT IN or NOT LIKE operators. E.g. following expressions should have same result, but parser fails to evaluate expressions without brackets correctly: {code:java} final Filterable message = mock(Filterable.class); when(message.getHeader("size")).thenReturn(10); when(message.getHeader("price")).thenReturn(100); assertTrue(new JMSSelectorFilter("not (size + price = 111)").matches(message)); assertTrue(new JMSSelectorFilter("not (price - size = 91)").matches(message)); assertTrue(new JMSSelectorFilter("not (price / size = 11)").matches(message)); assertTrue(new JMSSelectorFilter("not (price * size = 1001)").matches(message)); # failing assertions assertTrue(new JMSSelectorFilter("not size + price = 111").matches(message)); assertTrue(new JMSSelectorFilter("not price - size = 91").matches(message)); assertTrue(new JMSSelectorFilter("not price / size = 11").matches(message)); assertTrue(new JMSSelectorFilter("not price * size = 1001").matches(message)); {code} In expression "not size + price = 111" arithmetic operator should be evaluated as first, the comparison operator as second and logical NOT operator should be applied to the result, being an equivalent to the expression "not (size + price = 111)". But parser evaluates the expression as "not (size) + price = 111", leading to the exception "Cannot call plus operation on: true and: 100". In this case parser fails on the "not entry is null" expression, evaluating it as "not(entry) is null": {code:java} final Filterable message = mock(Filterable.class); when(message.getHeader("entry")).thenReturn("aaa"); assertTrue(new JMSSelectorFilter("entry is not null").matches(message)); assertTrue(new JMSSelectorFilter("not (entry is null)").matches(message)); # failing assertion assertTrue(new JMSSelectorFilter("not entry is null").matches(message)); {code} To address this issue we developed a PR changing this behavior and adding unit tests to cover the JMS selector parsing. > [Broker-J] Jms Selector Parsing - multiple AND's > ------------------------------------------------ > > Key: QPID-8674 > URL: https://issues.apache.org/jira/browse/QPID-8674 > Project: Qpid > Issue Type: Bug > Components: Broker-J > Affects Versions: qpid-java-broker-9.2.0 > Reporter: Kyrre > Priority: Major > Fix For: qpid-java-broker-9.2.1 > > Attachments: selectorSyntax.patch > > > When parsing a selector with 3 boolean expressions AND'ed together, the last > expression is not taken into account. > I have attached a patch file from the latest Github version of the main > branch to demostrate the problem. > In short, having a selector that evaluates (trueExpression) AND > (trueExpression) AND (falseExpression) evaluates to TRUE. > Patch of JMSSelectorFilterSyntaxTest.java below. > [^selectorSyntax.patch] > -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@qpid.apache.org For additional commands, e-mail: dev-h...@qpid.apache.org