SpEL PropertyAccessor
ordering for supertype and generic matches does not adhere to contract
#33861
Closed
4 tasks done
Labels
Milestone
Overview
The
PropertyAccessor
SPI in the Spring Expression Language (SpEL) defines agetSpecificTargetClasses()
method which allows an accessor to declare what types the accessor supports, ornull
if it is a "generic" accessor.The contract for ordering accessors is only partially mentioned in the Javadoc for
PropertyAccessor
; however, it is explained in detail in the Javadoc fororg.springframework.expression.spel.ast.AstUtils.getPropertyAccessorsToTry()
:And similar Javadoc exists for the private
getPropertyAccessorsToTry()
method inPropertyOrFieldReference
.However, the implementations of
AstUtils.getPropertyAccessorsToTry()
andPropertyOrFieldReference.getPropertyAccessorsToTry()
do not honor that last part of the contract.On the contrary, a generic accessor (such as
ReflectivePropertyAccessor
) is ordered before a customPropertyAccessor
that claims to support a supertype of the target type, if the generic accessor is registered before the custom accessor.In other words, a generic accessor can incorrectly take priority over a matching type-specific accessor.
Deliverables
AstUtils.getPropertyAccessorsToTry()
and remove the duplicate algorithm inPropertyOrFieldReference.getPropertyAccessorsToTry()
.AstUtils.getPropertyAccessorsToTry()
in6.1.x
andmain
.Related Issues
The text was updated successfully, but these errors were encountered: