Fix ActionPropertyAccessor
on Spring Framework 6.2
#1819
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Prior to this PR, if a Spring Expression Language (SpEL) expression did not include parentheses for a
MultiAction
method that does not accept aRequestContext
argument, the flow would pass on Spring Framework versions prior to 6.2, but the same flow would fail on Spring Framework 6.2 M1 or later. The following is such an expression and is effectively a property reference which must be handled by a registeredPropertyAccessor
:reportActions.evaluateReport
.The reason for the change in behavior is that Spring Framework 6.2 M1 includes a bug fix for ordering SpEL
PropertyAccessor
s. That bug fix correctly results in Spring Web Flow'sActionPropertyAccessor
being evaluated before SpEL'sReflectivePropertyAccessor
. Consequently, an expression such asreportActions.evaluateReport
is now handled byActionPropertyAccessor
which indirectly requires that the action method accept aRequestContext
argument. When the method does not accept aRequestContext
argument, the flow fails with aNoSuchMethodException
.To address that, this PR revises the implementation of
canRead(...)
inActionPropertyAccessor
so that it only returnstrue
if the action method accepts aRequestContext
argument. WhenActionPropertyAccessor
'scanRead(...)
method returnsfalse
, the genericReflectivePropertyAccessor
will be used instead, which restores the pre-6.2 behavior for such expressions.The test suite passes for the following Spring Framework versions.
./gradlew -PspringFrameworkVersion=6.0.23 --rerun-tasks clean check
./gradlew -PspringFrameworkVersion=6.1.14 --rerun-tasks clean check
./gradlew -PspringFrameworkVersion=6.2.0-RC3 --rerun-tasks clean check
Related Issues
PropertyAccessor
ordering for supertype and generic matches does not adhere to contract spring-framework#33861PropertyAccessor
andIndexAccessor
APIs regarding ordering spring-framework#33862