leaveWhite9088 opened a new issue, #11664:
URL: https://github.com/apache/rocketmq/issues/11664

   ### Before Creating the Bug Report
   
   - [x] I found a bug, not just asking a question, which should be created in 
[GitHub Discussions](https://github.com/apache/rocketmq/discussions).
   - [x] I have searched the [GitHub 
Issues](https://github.com/apache/rocketmq/issues) and [GitHub 
Discussions](https://github.com/apache/rocketmq/discussions) of this repository 
and believe that this is not a duplicate.
   - [x] I have confirmed that this bug belongs to the current repository, not 
other repositories of RocketMQ.
   
   ### Runtime platform environment
   
   OS: Windows 11 (platform-independent logic bug in `rocketmq-filter`)
   
   ### RocketMQ version
   
   - branch: `develop`
   - version: `5.5.1`
   - Git commit id: `19352a246`
   
   ### JDK Version
   
   Eclipse Temurin JDK 11.0.33
   
   ### Describe the Bug
   
   In 
`filter/src/main/java/org/apache/rocketmq/filter/expression/ComparisonExpression.java`,
 `ComparisonExpression#__compare` has two numeric promotion bugs when comparing 
mixed `Number` operands (for example, comparing parsed numeric constants on the 
left against typed numeric properties returned by an `EvaluationContext`):
   
   1. **`Double` vs `Float` throws `ClassCastException`**:
      When `lc == Double.class` and `rc == Float.class`, line 615 converts `rv` 
to `new Float(((Number) rv).doubleValue())` instead of `Double`, so the 
subsequent `lv.compareTo(rv)` (`Double.compareTo(Float)`) throws 
`ClassCastException`.
   2. **Asymmetric widening for `Byte` / `Short` on the right-hand side**:
      `__compare` widens `Byte` on the left when compared with 
`Short`/`Integer`/`Long`/`Float`/`Double`, but omits the symmetric branches 
when `Short`/`Integer`/`Long`/`Float`/`Double` is on the left and `Byte` or 
`Short` is on the right. Falling through to `return -1` causes incorrect 
boolean results (e.g., `10 < (byte) 1` evaluates to `true`, and `5 = (short) 5` 
evaluates to `false`).
   
   ### Steps to Reproduce
   
   Evaluate SQL filter expressions with `SelectorParser.parse(...)` against an 
`EvaluationContext` returning typed numeric properties:
   - `2.5 > a` with `a = 1.5f` -> throws `ClassCastException: Float cannot be 
cast to Double`.
   - `10 < a` with `a = (byte) 1` or `(short) 1` -> returns `true` instead of 
`false`.
   - `5 = a` with `a = (byte) 5` or `(short) 5` -> returns `false` instead of 
`true`.
   
   ### What Did You Expect to See?
   
   - `2.5 > 1.5f` evaluates to `true` without throwing `ClassCastException`.
   - Mixed comparisons between `Byte`/`Short`/`Integer`/`Long`/`Float`/`Double` 
widen symmetrically and return accurate comparison results.
   
   ### What Did You See Instead?
   
   `Double` vs `Float` throws `ClassCastException`, and wider numeric types on 
the left compared with `Byte`/`Short` on the right fall back to `-1`.
   


-- 
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]

Reply via email to