-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
Support varargs invocations in SpEL for varargs array subtype #32704
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Could you add
|
That's to be expected: when |
Do you mean that you have a second fix for which you plan to submit a PR that will address the following TODO regarding compilation of varargs method invocations? // TODO Determine why the String[] is passed as the first element of the Object... varargs array instead of the entire varargs array. |
@dcollins123, |
SpEL has supported varargs invocations for methods and constructors for quite a while with the limitation that the supplied array must match the declared varargs type. In light of that, we consider this an "enhancement" rather than a "bug", and we will include this in the upcoming |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the raising the issue, the PR itself, and for the additional tests for var-args invocations.
I left a few comments which I will address locally before merging.
...g-expression/src/main/java/org/springframework/expression/spel/support/ReflectionHelper.java
Show resolved
Hide resolved
...g-expression/src/main/java/org/springframework/expression/spel/support/ReflectionHelper.java
Show resolved
Hide resolved
Yes, exactly. |
@LeMikaelF, that would be great! |
There was a bug in SpEL where an array passed into a varargs method could be wrapped one too many times if the component type of the argument didn't match the component type of the parameter. For example:
This fails with the following error message:
I've added more exhaustive test cases for the method where the bug was, as well as a test in
SpelCompilationCoverageTests
. I've added this last test just next to another test that was commented out with a TODO, and had to comment out part of my test because of the same bug, but fixing this exposes another underlying bug that I've fixed in another branch, and I was able to uncomment the tests that were commented out. The fix is ready, I'm just waiting for this one to be merged.I may also have accidentally uncovered another bug in SpEL. At line 4651 in
SpelCompilationCoverageTests
, the methodseventeen()
isn't actually invoked with()
, yet it's still executed and its result value is available. I'm not sure this is desirable behaviour.