Uploaded image for project: 'ActiveMQ Classic'
  1. ActiveMQ Classic
  2. AMQ-2528

org.apache.activemq.broker.region.Queue#removeMatchingMessages(String selector) does not allow empty string as a selector, but empty string is a valid JMS message selector.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 5.3.0
    • 5.6.0
    • Selector
    • None
    • Unit Test Broken

    Description

      According to the JMS specification, an "empty string" message selector indicates no message selector (i.e., all messages should be selected):

      "A message selector is a String whose syntax is based on a subset of the SQL92 conditional expression syntax. If the value of a message selector is an empty string, the value is treated as a null and indicates that there is no message selector for the message consumer."

      However, if org.apache.activemq.broker.region.Queue#removeMatchingMessages(String selector) with selector = "", the following stacktrace is generated:

      javax.jms.InvalidSelectorException:
      at org.apache.activemq.selector.SelectorParser.parse(SelectorParser.java:72)
      at org.apache.activemq.selector.SelectorParser.parse(SelectorParser.java:46)
      at org.apache.activemq.broker.region.Queue.createSelectorFilter(Queue.java:1200)
      at org.apache.activemq.broker.region.Queue.removeMatchingMessages(Queue.java:908)
      at org.apache.activemq.broker.region.Queue.removeMatchingMessages(Queue.java:898)
      at com.invoqsystems.foundation.utility.AMQUtility.deleteMessages(AMQUtility.java:192)
      at com.invoqsystems.foundation.utility.AMQUtilityTest.testDeleteMessages(AMQUtilityTest.java:187)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
      at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
      at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
      at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
      at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
      at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:71)
      at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
      at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
      at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
      at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
      Caused by: org.apache.activemq.selector.ParseException: Parse error at line 0, column 0. Encountered: <EOF>
      at org.apache.activemq.selector.SelectorParser.generateParseException(SelectorParser.java:1196)
      at org.apache.activemq.selector.SelectorParser.jj_consume_token(SelectorParser.java:1148)
      at org.apache.activemq.selector.SelectorParser.unaryExpr(SelectorParser.java:453)
      at org.apache.activemq.selector.SelectorParser.multExpr(SelectorParser.java:375)
      at org.apache.activemq.selector.SelectorParser.addExpression(SelectorParser.java:344)
      at org.apache.activemq.selector.SelectorParser.comparisonExpression(SelectorParser.java:196)
      at org.apache.activemq.selector.SelectorParser.equalityExpression(SelectorParser.java:141)
      at org.apache.activemq.selector.SelectorParser.andExpression(SelectorParser.java:120)
      at org.apache.activemq.selector.SelectorParser.orExpression(SelectorParser.java:99)
      at org.apache.activemq.selector.SelectorParser.JmsSelector(SelectorParser.java:91)
      at org.apache.activemq.selector.SelectorParser.parse(SelectorParser.java:69)
      ... 26 more

      Attachments

        1. AMQ2528Test.java
          2 kB
          Stirling Chow

        Activity

          People

            Unassigned Unassigned
            stirlingc Stirling Chow
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: