SpEL: problem with static methods conflicting with instance methods [SPR-12502] #17107
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: backported
An issue that has been backported to maintenance branches
type: bug
A general bug
Milestone
Andy Clement opened SPR-12502 and commented
This problem came up in Spring XD and I think has come up before. Consider this testcode:
The code in ReflectiveMethodResolver.getMethods() tries to ensure static methods are easily callable so merges two sets of candidates together. This causes problems above because the root object User supports getName() but we want to invoke the getName() on the Class object. Now it sometimes works and picks the right one - depending on the JDK you run it on. That variation is due to the ordering of elements from a collection changing across JDKs. No ordering was specified so that isn't unreasonable...
The solution is to change getMethods() - ensure the ordering is fixed by using a LinkedHashSet rather than a HashSet and ensure the candidates we are most likely interested in are first.
Affects: 3.2.12, 4.0.8, 4.1.2
Attachments:
Issue Links:
Backported to: 4.0.9, 3.2.13
The text was updated successfully, but these errors were encountered: