Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpEL cannot invoke varargs MethodHandle function with zero variable arguments #33190

Closed
sbrannen opened this issue Jul 10, 2024 · 0 comments
Closed
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Milestone

Comments

@sbrannen
Copy link
Member

sbrannen commented Jul 10, 2024

The Spring Expression Language (SpEL) currently cannot invoke a varargs MethodHandle function with zero variable arguments.

Attempting to do so results in a SpelEvaluationException with an INCORRECT_NUMBER_OF_ARGUMENTS_TO_FUNCTION message.

For example, given a MethodHandle registered as a function named format that accepts (String, Object...), the SpEL expression #format('x', 42) is supported, but the expression #format('x') fails even though the variable arguments are not required.

The following assertion in our test suite should therefore not actually fail due to a SpelEvaluationException with an INCORRECT_NUMBER_OF_ARGUMENTS_TO_FUNCTION message but rather due to an exception thrown from java.lang.String.formatted(Object...), which that #message() function invokes on the first argument.

evaluateAndCheckError("#message('%s')", INCORRECT_NUMBER_OF_ARGUMENTS_TO_FUNCTION, 0, "message", 1, 2);

@sbrannen sbrannen added type: bug A general bug in: core Issues in core modules (aop, beans, core, context, expression) labels Jul 10, 2024
@sbrannen sbrannen added this to the 6.1.11 milestone Jul 10, 2024
@sbrannen sbrannen self-assigned this Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

1 participant