You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2020/02/19 18:09:48 UTC

[GitHub] [commons-lang] kinow commented on a change in pull request #494: LANG-1518 - fix searchSupers for generic classes

kinow commented on a change in pull request #494: LANG-1518 - fix searchSupers for generic classes
URL: https://github.com/apache/commons-lang/pull/494#discussion_r381451626
 
 

 ##########
 File path: src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
 ##########
 @@ -974,17 +974,13 @@ private static int distance(final Class<?>[] classArray, final Class<?>[] toClas
             final Class<?> mcls = method.getDeclaringClass();
             final List<Class<?>> classes = getAllSuperclassesAndInterfaces(mcls);
             for (final Class<?> acls : classes) {
-                Method equivalentMethod;
-                try {
-                    equivalentMethod = (ignoreAccess ? acls.getDeclaredMethod(method.getName(), method.getParameterTypes())
-                            : acls.getMethod(method.getName(), method.getParameterTypes()));
-                } catch (final NoSuchMethodException e) {
-                    // if not found, just keep searching
-                    continue;
-                }
-                annotation = equivalentMethod.getAnnotation(annotationCls);
-                if (annotation != null) {
-                    break;
+                Method equivalentMethod = (ignoreAccess ? MethodUtils.getMatchingMethod(acls, method.getName(), method.getParameterTypes())
+                    : MethodUtils.getMatchingAccessibleMethod(acls, method.getName(), method.getParameterTypes()));
+                if(equivalentMethod != null) {
 
 Review comment:
   I think Travis is failing here
   
   ```
   /checkstyle.xml ruleset.
   
   [ERROR] src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java:[979,17] (whitespace) WhitespaceAfter: 'if' is not followed by whitespace.
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services