Skip to content

Commit 9c440d3

Browse files
committed
Fix IndexOutOfBoundsException in ReflectionUtils
When looking for overridden methods, if the superclass or interface that is being used has overloaded methods with the same name, an IndexOutOfBoundsException will be generated (on line 93 in old code), because the code is not checking for the array lengths and using the length of the methodToFind.getParameterTypes to iterate arrays of different length.
1 parent 400662d commit 9c440d3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

modules/swagger-jaxrs/src/main/java/io/swagger/jaxrs/utils/ReflectionUtils.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ public static Method findMethod(Method methodToFind, Class<?> cls) {
8383
Type[] gpTypes = methodToFind.getGenericParameterTypes();
8484
methodLoop:
8585
for (Method method : cls.getMethods()) {
86-
if (!method.getName().equals(methodToSearch) || !method.getReturnType().isAssignableFrom(methodToFind.getReturnType())) {
86+
if (
87+
!method.getName().equals(methodToSearch) ||
88+
!method.getReturnType().isAssignableFrom(methodToFind.getReturnType()) ||
89+
method.getParameterTypes().length != pTypes.length
90+
) {
8791
continue;
8892
}
8993
Class<?>[] pt = method.getParameterTypes();

0 commit comments

Comments
 (0)