RockteMQ-AI commented on issue #11437:
URL: https://github.com/apache/rocketmq/issues/11437#issuecomment-6166898813
## ๐ค Bot Evaluation: โ
Bug Confirmed
**Category:** `type/bug`
**Severity:** Medium โ silent data loss in message filtering; consumers
receive messages that should have been filtered out.
### Verification
I verified the bug by inspecting the source code on `develop` branch:
1.
**`filter/src/main/java/org/apache/rocketmq/filter/parser/SelectorParser.java`**
โ The `JmsSelector()` start rule parses one `orExpression()` and returns
immediately. There is no `jj_consume_token(0)` or equivalent EOF check anywhere
in the file.
2.
**`filter/src/main/java/org/apache/rocketmq/filter/parser/SelectorParser.jj`**
(lines 200โ210) โ The grammar rule for `JmsSelector()` has no `<EOF>` token at
the end:
```
BooleanExpression JmsSelector() :
{ Expression left=null; }
{
( left = orExpression() )
{ return asBooleanExpression(left); }
}
```
3. **Impact confirmed:** `SelectorParser.parse("a = 3 b = 4")` returns `(a =
3)` โ the second clause is silently dropped. This affects both client-side
subscription (`MessageSelector.bySql(...)`) and broker-side filter compilation
(`SqlFilter.compile(...)` via `ConsumerFilterManager.build`).
### Root Cause
The JavaCC-generated parser consumes only as much input as matches the
grammar and never asserts that the entire input string was consumed. Any
trailing tokens after a valid expression are silently ignored.
### Suggested Fix
Add `<EOF>` to the grammar rule in `SelectorParser.jj`:
```
BooleanExpression JmsSelector() :
{ Expression left=null; }
{
( left = orExpression() ) <EOF>
{ return asBooleanExpression(left); }
}
```
Then regenerate `SelectorParser.java` from the grammar. This will cause the
parser to throw a `ParseException` when trailing tokens remain.
### Notes
- The issue description is thorough and well-reproduced. Thank you
@iloveeyjafjalla!
- The referenced PR #602 (2018) attempted a similar fix but was not merged.
- The author mentioned they will open a PR โ looking forward to it.
---
*Evaluated by [RockteMQ-AI](https://github.com/RockteMQ-AI) bot ยท Issue
evaluation workflow*
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]