Skip to content

Commit aeef000

Browse files
committed
Fixed ReflectiveMethodResolver to avoid potential UnsupportedOperationException on sort
Issue: SPR-10392
1 parent 283b3ee commit aeef000

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveMethodResolver.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,15 @@ public MethodExecutor resolve(EvaluationContext context, Object targetObject, St
103103
}
104104

105105
// Sort methods into a sensible order
106-
Collections.sort(methods, new Comparator<Method>() {
107-
public int compare(Method m1, Method m2) {
108-
int m1pl = m1.getParameterTypes().length;
109-
int m2pl = m2.getParameterTypes().length;
110-
return (new Integer(m1pl)).compareTo(m2pl);
111-
}
112-
});
106+
if (methods.size() > 1) {
107+
Collections.sort(methods, new Comparator<Method>() {
108+
public int compare(Method m1, Method m2) {
109+
int m1pl = m1.getParameterTypes().length;
110+
int m2pl = m2.getParameterTypes().length;
111+
return (new Integer(m1pl)).compareTo(m2pl);
112+
}
113+
});
114+
}
113115

114116
// Resolve any bridge methods
115117
for (int i = 0; i < methods.size(); i++) {

0 commit comments

Comments
 (0)