Skip to content

Parse long literals in FilterExpressionTextParser - #6701

Open
wxggzz wants to merge 1 commit into
spring-projects:mainfrom
wxggzz:fix/filter-parser-long-literal
Open

Parse long literals in FilterExpressionTextParser#6701
wxggzz wants to merge 1 commit into
spring-projects:mainfrom
wxggzz:fix/filter-parser-long-literal

Conversation

@wxggzz

@wxggzz wxggzz commented Jul 29, 2026

Copy link
Copy Markdown

What

FilterExpressionTextParser parsed every bare integer literal as Integer, so a filter expression whose value exceeds the int range — e.g. a long metadata id used when deleting by id — failed with:

java.lang.NumberFormatException: For input string: "9223372036854775807"

Fix

visitIntegerConstant now falls back to Long when the literal doesn't fit in an int, while still returning Integer for smaller values (backward compatible). Literals with an explicit L suffix keep going through the existing visitLongConstant path, and values inside IN/NIN arrays are covered too since they delegate to the same visitor.

Tests

Added testLongValueLiteral covering Long.MAX_VALUE / Long.MIN_VALUE and asserting that in-range values still parse as Integer. All 16 parser tests pass locally:

./mvnw -pl spring-ai-vector-store -am -Dtest=FilterExpressionTextParserTests -Dsurefire.failIfNoSpecifiedTests=false test

Fixes #4705

Numeric literals without an `L` suffix were always parsed as `Integer`,
so filter expressions with values outside the int range (for example a
`long` metadata id) failed with a `NumberFormatException`.

Fall back to `Long` when the literal exceeds the int range, keeping the
existing `Integer` result for smaller values.

Fixes spring-projects#4705

Signed-off-by: wxggzz <weixiegen0506@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FilterExpressionTextParser treats all number literals as Integer, failing on Long values

2 participants