[jira] [Work logged] (LANG-1544) MethodUtils.invokeMethod NullPointerException in case of null in args list

2020-12-22 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1544?focusedWorklogId=527345=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-527345
 ]

ASF GitHub Bot logged work on LANG-1544:


Author: ASF GitHub Bot
Created on: 22/Dec/20 20:12
Start Date: 22/Dec/20 20:12
Worklog Time Spent: 10m 
  Work Description: garydgregory merged pull request #680:
URL: https://github.com/apache/commons-lang/pull/680


   



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:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 527345)
Time Spent: 3h 40m  (was: 3.5h)

> MethodUtils.invokeMethod NullPointerException in case of null in args list
> --
>
> Key: LANG-1544
> URL: https://issues.apache.org/jira/browse/LANG-1544
> Project: Commons Lang
>  Issue Type: Bug
>  Components: lang.reflect.*
>Affects Versions: 3.10
>Reporter: Peter Nagy
>Priority: Critical
>  Time Spent: 3h 40m
>  Remaining Estimate: 0h
>
> MethodUtils:774
>  
> if (classArray[offset].equals(toClassArray[offset])) {
>  continue;
> } else if (ClassUtils.isAssignable(classArray[offset], toClassArray[offset], 
> true)
>  
> cause NPE if classArray[offset] is null. Can you please extend the if 
> condition with a null check, like this?
>  
> if (classArray[offset] != null && 
> classArray[offset].equals(toClassArray[offset]))



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (LANG-1544) MethodUtils.invokeMethod NullPointerException in case of null in args list

2020-12-22 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1544?focusedWorklogId=527305=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-527305
 ]

ASF GitHub Bot logged work on LANG-1544:


Author: ASF GitHub Bot
Created on: 22/Dec/20 18:13
Start Date: 22/Dec/20 18:13
Worklog Time Spent: 10m 
  Work Description: coveralls edited a comment on pull request #680:
URL: https://github.com/apache/commons-lang/pull/680#issuecomment-749221904


   
   [![Coverage 
Status](https://coveralls.io/builds/35897811/badge)](https://coveralls.io/builds/35897811)
   
   Coverage increased (+0.003%) to 95.02% when pulling 
**dcc01d911c1f0433f49123ef15873e386b5d45a8 on 
mdbuck77:LANG-1544_MethodUtils_Throws_NPE** into 
**c9e825e823e30c5b1e3ddc9de5e8fd0094d52ee5 on apache:master**.
   



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:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 527305)
Time Spent: 3.5h  (was: 3h 20m)

> MethodUtils.invokeMethod NullPointerException in case of null in args list
> --
>
> Key: LANG-1544
> URL: https://issues.apache.org/jira/browse/LANG-1544
> Project: Commons Lang
>  Issue Type: Bug
>  Components: lang.reflect.*
>Affects Versions: 3.10
>Reporter: Peter Nagy
>Priority: Critical
>  Time Spent: 3.5h
>  Remaining Estimate: 0h
>
> MethodUtils:774
>  
> if (classArray[offset].equals(toClassArray[offset])) {
>  continue;
> } else if (ClassUtils.isAssignable(classArray[offset], toClassArray[offset], 
> true)
>  
> cause NPE if classArray[offset] is null. Can you please extend the if 
> condition with a null check, like this?
>  
> if (classArray[offset] != null && 
> classArray[offset].equals(toClassArray[offset]))



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (LANG-1544) MethodUtils.invokeMethod NullPointerException in case of null in args list

2020-12-22 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1544?focusedWorklogId=527285=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-527285
 ]

ASF GitHub Bot logged work on LANG-1544:


Author: ASF GitHub Bot
Created on: 22/Dec/20 17:11
Start Date: 22/Dec/20 17:11
Worklog Time Spent: 10m 
  Work Description: mdbuck77 commented on a change in pull request #680:
URL: https://github.com/apache/commons-lang/pull/680#discussion_r547396391



##
File path: src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
##
@@ -742,35 +745,51 @@ public static Method getMatchingMethod(final Class 
cls, final String methodNa
 Validate.notNull(cls, "cls");
 Validate.notEmpty(methodName, "methodName");
 
-// Address methods in superclasses
-Method[] methodArray = cls.getDeclaredMethods();
-final List> superclassList = 
ClassUtils.getAllSuperclasses(cls);
-for (final Class klass : superclassList) {
-methodArray = ArrayUtils.addAll(methodArray, 
klass.getDeclaredMethods());
-}
+final List methods = Arrays.stream(cls.getDeclaredMethods())
+.filter(method -> method.getName().equals(methodName))
+.collect(toList());
+
+ClassUtils.getAllSuperclasses(cls).stream()
+.map(Class::getDeclaredMethods)
+.flatMap(Arrays::stream)
+.filter(method -> method.getName().equals(methodName))
+.forEach(methods::add);
 
-Method inexactMatch = null;
-for (final Method method : methodArray) {
-if (methodName.equals(method.getName()) &&
-Objects.deepEquals(parameterTypes, 
method.getParameterTypes())) {
+for (Method method : methods) {
+if (Arrays.deepEquals(method.getParameterTypes(), parameterTypes)) 
{
 return method;
-} else if (methodName.equals(method.getName()) &&
-ClassUtils.isAssignable(parameterTypes, 
method.getParameterTypes(), true)) {
-if ((inexactMatch == null) || (distance(parameterTypes, 
method.getParameterTypes())
-< distance(parameterTypes, 
inexactMatch.getParameterTypes( {
-inexactMatch = method;
-}
 }
+}
+
+final TreeMap> candidates = new TreeMap<>();
 
+methods.stream()
+.filter(method -> ClassUtils.isAssignable(parameterTypes, 
method.getParameterTypes(), true))
+.forEach(method -> {
+final double distance = distance(parameterTypes, 
method.getParameterTypes());
+List methods1 = 
candidates.computeIfAbsent(distance, k -> new ArrayList<>());
+methods1.add(method);
+});
+
+if (candidates.isEmpty()) {
+return null;
 }
-return inexactMatch;
+
+final List bestCandidates = 
candidates.values().iterator().next();
+if (bestCandidates.size() == 1) {
+return bestCandidates.get(0);
+}
+
+final String target = methodName + 
Arrays.stream(parameterTypes).map(String::valueOf).collect(Collectors.joining(",",
 "(", ")"));
+final String strCandidates = 
bestCandidates.stream().map(Method::toString).collect(Collectors.joining("\n  
"));
+throw new IllegalStateException("Found multiple candidates for method 
" + target + " on class " + cls + ":\n  " + strCandidates);
 }
 
 /**
  * Returns the aggregate number of inheritance hops between assignable 
argument class types.  Returns -1
  * if the arguments aren't assignable.  Fills a specific purpose for 
getMatchingMethod and is not generalized.
- * @param classArray
- * @param toClassArray
+ * @param classArray the Class array to calculate the distance from.

Review comment:
   Good suggestion. Done.
   
   Michael





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:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 527285)
Time Spent: 3h 20m  (was: 3h 10m)

> MethodUtils.invokeMethod NullPointerException in case of null in args list
> --
>
> Key: LANG-1544
> URL: https://issues.apache.org/jira/browse/LANG-1544
> Project: Commons Lang
>  Issue Type: Bug
>  Components: lang.reflect.*
>Affects Versions: 3.10
>Reporter: Peter Nagy
>Priority: Critical
>  Time Spent: 3h 20m
>  

[jira] [Work logged] (LANG-1544) MethodUtils.invokeMethod NullPointerException in case of null in args list

2020-12-22 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1544?focusedWorklogId=527282=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-527282
 ]

ASF GitHub Bot logged work on LANG-1544:


Author: ASF GitHub Bot
Created on: 22/Dec/20 17:10
Start Date: 22/Dec/20 17:10
Worklog Time Spent: 10m 
  Work Description: mdbuck77 commented on a change in pull request #680:
URL: https://github.com/apache/commons-lang/pull/680#discussion_r547395975



##
File path: src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
##
@@ -742,35 +745,51 @@ public static Method getMatchingMethod(final Class 
cls, final String methodNa
 Validate.notNull(cls, "cls");
 Validate.notEmpty(methodName, "methodName");
 
-// Address methods in superclasses
-Method[] methodArray = cls.getDeclaredMethods();
-final List> superclassList = 
ClassUtils.getAllSuperclasses(cls);
-for (final Class klass : superclassList) {
-methodArray = ArrayUtils.addAll(methodArray, 
klass.getDeclaredMethods());
-}
+final List methods = Arrays.stream(cls.getDeclaredMethods())
+.filter(method -> method.getName().equals(methodName))
+.collect(toList());
+
+ClassUtils.getAllSuperclasses(cls).stream()
+.map(Class::getDeclaredMethods)
+.flatMap(Arrays::stream)
+.filter(method -> method.getName().equals(methodName))
+.forEach(methods::add);
 
-Method inexactMatch = null;
-for (final Method method : methodArray) {
-if (methodName.equals(method.getName()) &&
-Objects.deepEquals(parameterTypes, 
method.getParameterTypes())) {
+for (Method method : methods) {
+if (Arrays.deepEquals(method.getParameterTypes(), parameterTypes)) 
{
 return method;
-} else if (methodName.equals(method.getName()) &&
-ClassUtils.isAssignable(parameterTypes, 
method.getParameterTypes(), true)) {
-if ((inexactMatch == null) || (distance(parameterTypes, 
method.getParameterTypes())
-< distance(parameterTypes, 
inexactMatch.getParameterTypes( {
-inexactMatch = method;
-}
 }
+}
+
+final TreeMap> candidates = new TreeMap<>();
 
+methods.stream()
+.filter(method -> ClassUtils.isAssignable(parameterTypes, 
method.getParameterTypes(), true))
+.forEach(method -> {
+final double distance = distance(parameterTypes, 
method.getParameterTypes());
+List methods1 = 
candidates.computeIfAbsent(distance, k -> new ArrayList<>());
+methods1.add(method);
+});
+
+if (candidates.isEmpty()) {
+return null;
 }
-return inexactMatch;
+
+final List bestCandidates = 
candidates.values().iterator().next();
+if (bestCandidates.size() == 1) {
+return bestCandidates.get(0);
+}
+
+final String target = methodName + 
Arrays.stream(parameterTypes).map(String::valueOf).collect(Collectors.joining(",",
 "(", ")"));
+final String strCandidates = 
bestCandidates.stream().map(Method::toString).collect(Collectors.joining("\n  
"));
+throw new IllegalStateException("Found multiple candidates for method 
" + target + " on class " + cls + ":\n  " + strCandidates);

Review comment:
   I replaced the newlines with opening and closing brackets.
   
   Michael





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:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 527282)
Time Spent: 2h 50m  (was: 2h 40m)

> MethodUtils.invokeMethod NullPointerException in case of null in args list
> --
>
> Key: LANG-1544
> URL: https://issues.apache.org/jira/browse/LANG-1544
> Project: Commons Lang
>  Issue Type: Bug
>  Components: lang.reflect.*
>Affects Versions: 3.10
>Reporter: Peter Nagy
>Priority: Critical
>  Time Spent: 2h 50m
>  Remaining Estimate: 0h
>
> MethodUtils:774
>  
> if (classArray[offset].equals(toClassArray[offset])) {
>  continue;
> } else if (ClassUtils.isAssignable(classArray[offset], toClassArray[offset], 
> true)
>  
> cause NPE if classArray[offset] is null. Can you please extend the if 
> condition with a null check, like this?
>  
> if 

[jira] [Work logged] (LANG-1544) MethodUtils.invokeMethod NullPointerException in case of null in args list

2020-12-22 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1544?focusedWorklogId=527283=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-527283
 ]

ASF GitHub Bot logged work on LANG-1544:


Author: ASF GitHub Bot
Created on: 22/Dec/20 17:10
Start Date: 22/Dec/20 17:10
Worklog Time Spent: 10m 
  Work Description: mdbuck77 commented on a change in pull request #680:
URL: https://github.com/apache/commons-lang/pull/680#discussion_r547396104



##
File path: src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java
##
@@ -1018,4 +1019,83 @@ public void testDistance() throws Exception {
 
 distanceMethod.setAccessible(false);
 }
+
+@Test
+public void testGetMatchingMethod() throws NoSuchMethodException {
+
assertEquals(MethodUtils.getMatchingMethod(GetMatchingMethodClass.class, 
"testMethod"),
+GetMatchingMethodClass.class.getMethod("testMethod"));
+
+
assertEquals(MethodUtils.getMatchingMethod(GetMatchingMethodClass.class, 
"testMethod", Long.TYPE),
+GetMatchingMethodClass.class.getMethod("testMethod", 
Long.TYPE));
+
+
assertEquals(MethodUtils.getMatchingMethod(GetMatchingMethodClass.class, 
"testMethod", Long.class),
+GetMatchingMethodClass.class.getMethod("testMethod", 
Long.class));
+
+
assertEquals(MethodUtils.getMatchingMethod(GetMatchingMethodClass.class, 
"testMethod", (Class) null),
+GetMatchingMethodClass.class.getMethod("testMethod", 
Long.class));
+
+assertThrows(IllegalStateException.class,
+() -> 
MethodUtils.getMatchingMethod(GetMatchingMethodClass.class, "testMethod2", 
(Class) null));
+
+
assertEquals(MethodUtils.getMatchingMethod(GetMatchingMethodClass.class, 
"testMethod3", Long.TYPE, Long.class),
+GetMatchingMethodClass.class.getMethod("testMethod3", 
Long.TYPE, Long.class));
+
+
assertEquals(MethodUtils.getMatchingMethod(GetMatchingMethodClass.class, 
"testMethod3", Long.class, Long.TYPE),
+GetMatchingMethodClass.class.getMethod("testMethod3", 
Long.class, Long.TYPE));
+
+
assertEquals(MethodUtils.getMatchingMethod(GetMatchingMethodClass.class, 
"testMethod3", null, Long.TYPE),
+GetMatchingMethodClass.class.getMethod("testMethod3", 
Long.class, Long.TYPE));
+
+
assertEquals(MethodUtils.getMatchingMethod(GetMatchingMethodClass.class, 
"testMethod3", Long.TYPE, null),
+GetMatchingMethodClass.class.getMethod("testMethod3", 
Long.TYPE, Long.class));
+
+assertThrows(IllegalStateException.class,
+() -> 
MethodUtils.getMatchingMethod(GetMatchingMethodClass.class, "testMethod4", 
null, null));
+}
+
+private static final class GetMatchingMethodClass {
+public String testMethod() {
+return "testMethod";
+}
+
+public String testMethod(Long aLong) {

Review comment:
   Done.
   
   Michael





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:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 527283)
Time Spent: 3h  (was: 2h 50m)

> MethodUtils.invokeMethod NullPointerException in case of null in args list
> --
>
> Key: LANG-1544
> URL: https://issues.apache.org/jira/browse/LANG-1544
> Project: Commons Lang
>  Issue Type: Bug
>  Components: lang.reflect.*
>Affects Versions: 3.10
>Reporter: Peter Nagy
>Priority: Critical
>  Time Spent: 3h
>  Remaining Estimate: 0h
>
> MethodUtils:774
>  
> if (classArray[offset].equals(toClassArray[offset])) {
>  continue;
> } else if (ClassUtils.isAssignable(classArray[offset], toClassArray[offset], 
> true)
>  
> cause NPE if classArray[offset] is null. Can you please extend the if 
> condition with a null check, like this?
>  
> if (classArray[offset] != null && 
> classArray[offset].equals(toClassArray[offset]))



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (LANG-1544) MethodUtils.invokeMethod NullPointerException in case of null in args list

2020-12-22 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1544?focusedWorklogId=527284=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-527284
 ]

ASF GitHub Bot logged work on LANG-1544:


Author: ASF GitHub Bot
Created on: 22/Dec/20 17:10
Start Date: 22/Dec/20 17:10
Worklog Time Spent: 10m 
  Work Description: mdbuck77 commented on a change in pull request #680:
URL: https://github.com/apache/commons-lang/pull/680#discussion_r547396204



##
File path: src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java
##
@@ -1018,4 +1019,83 @@ public void testDistance() throws Exception {
 
 distanceMethod.setAccessible(false);
 }
+
+@Test
+public void testGetMatchingMethod() throws NoSuchMethodException {
+
assertEquals(MethodUtils.getMatchingMethod(GetMatchingMethodClass.class, 
"testMethod"),
+GetMatchingMethodClass.class.getMethod("testMethod"));
+
+
assertEquals(MethodUtils.getMatchingMethod(GetMatchingMethodClass.class, 
"testMethod", Long.TYPE),
+GetMatchingMethodClass.class.getMethod("testMethod", 
Long.TYPE));
+
+
assertEquals(MethodUtils.getMatchingMethod(GetMatchingMethodClass.class, 
"testMethod", Long.class),
+GetMatchingMethodClass.class.getMethod("testMethod", 
Long.class));
+
+
assertEquals(MethodUtils.getMatchingMethod(GetMatchingMethodClass.class, 
"testMethod", (Class) null),
+GetMatchingMethodClass.class.getMethod("testMethod", 
Long.class));
+
+assertThrows(IllegalStateException.class,
+() -> 
MethodUtils.getMatchingMethod(GetMatchingMethodClass.class, "testMethod2", 
(Class) null));
+
+
assertEquals(MethodUtils.getMatchingMethod(GetMatchingMethodClass.class, 
"testMethod3", Long.TYPE, Long.class),
+GetMatchingMethodClass.class.getMethod("testMethod3", 
Long.TYPE, Long.class));
+
+
assertEquals(MethodUtils.getMatchingMethod(GetMatchingMethodClass.class, 
"testMethod3", Long.class, Long.TYPE),
+GetMatchingMethodClass.class.getMethod("testMethod3", 
Long.class, Long.TYPE));
+
+
assertEquals(MethodUtils.getMatchingMethod(GetMatchingMethodClass.class, 
"testMethod3", null, Long.TYPE),
+GetMatchingMethodClass.class.getMethod("testMethod3", 
Long.class, Long.TYPE));
+
+
assertEquals(MethodUtils.getMatchingMethod(GetMatchingMethodClass.class, 
"testMethod3", Long.TYPE, null),
+GetMatchingMethodClass.class.getMethod("testMethod3", 
Long.TYPE, Long.class));
+
+assertThrows(IllegalStateException.class,
+() -> 
MethodUtils.getMatchingMethod(GetMatchingMethodClass.class, "testMethod4", 
null, null));
+}
+
+private static final class GetMatchingMethodClass {

Review comment:
   Done.
   
   Michael





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:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 527284)
Time Spent: 3h 10m  (was: 3h)

> MethodUtils.invokeMethod NullPointerException in case of null in args list
> --
>
> Key: LANG-1544
> URL: https://issues.apache.org/jira/browse/LANG-1544
> Project: Commons Lang
>  Issue Type: Bug
>  Components: lang.reflect.*
>Affects Versions: 3.10
>Reporter: Peter Nagy
>Priority: Critical
>  Time Spent: 3h 10m
>  Remaining Estimate: 0h
>
> MethodUtils:774
>  
> if (classArray[offset].equals(toClassArray[offset])) {
>  continue;
> } else if (ClassUtils.isAssignable(classArray[offset], toClassArray[offset], 
> true)
>  
> cause NPE if classArray[offset] is null. Can you please extend the if 
> condition with a null check, like this?
>  
> if (classArray[offset] != null && 
> classArray[offset].equals(toClassArray[offset]))



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (LANG-1544) MethodUtils.invokeMethod NullPointerException in case of null in args list

2020-12-22 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1544?focusedWorklogId=527237=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-527237
 ]

ASF GitHub Bot logged work on LANG-1544:


Author: ASF GitHub Bot
Created on: 22/Dec/20 15:21
Start Date: 22/Dec/20 15:21
Worklog Time Spent: 10m 
  Work Description: garydgregory commented on a change in pull request #680:
URL: https://github.com/apache/commons-lang/pull/680#discussion_r547326472



##
File path: src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
##
@@ -742,35 +745,51 @@ public static Method getMatchingMethod(final Class 
cls, final String methodNa
 Validate.notNull(cls, "cls");
 Validate.notEmpty(methodName, "methodName");
 
-// Address methods in superclasses
-Method[] methodArray = cls.getDeclaredMethods();
-final List> superclassList = 
ClassUtils.getAllSuperclasses(cls);
-for (final Class klass : superclassList) {
-methodArray = ArrayUtils.addAll(methodArray, 
klass.getDeclaredMethods());
-}
+final List methods = Arrays.stream(cls.getDeclaredMethods())
+.filter(method -> method.getName().equals(methodName))
+.collect(toList());
+
+ClassUtils.getAllSuperclasses(cls).stream()
+.map(Class::getDeclaredMethods)
+.flatMap(Arrays::stream)
+.filter(method -> method.getName().equals(methodName))
+.forEach(methods::add);
 
-Method inexactMatch = null;
-for (final Method method : methodArray) {
-if (methodName.equals(method.getName()) &&
-Objects.deepEquals(parameterTypes, 
method.getParameterTypes())) {
+for (Method method : methods) {
+if (Arrays.deepEquals(method.getParameterTypes(), parameterTypes)) 
{
 return method;
-} else if (methodName.equals(method.getName()) &&
-ClassUtils.isAssignable(parameterTypes, 
method.getParameterTypes(), true)) {
-if ((inexactMatch == null) || (distance(parameterTypes, 
method.getParameterTypes())
-< distance(parameterTypes, 
inexactMatch.getParameterTypes( {
-inexactMatch = method;
-}
 }
+}
+
+final TreeMap> candidates = new TreeMap<>();
 
+methods.stream()
+.filter(method -> ClassUtils.isAssignable(parameterTypes, 
method.getParameterTypes(), true))
+.forEach(method -> {
+final double distance = distance(parameterTypes, 
method.getParameterTypes());
+List methods1 = 
candidates.computeIfAbsent(distance, k -> new ArrayList<>());
+methods1.add(method);
+});
+
+if (candidates.isEmpty()) {
+return null;
 }
-return inexactMatch;
+
+final List bestCandidates = 
candidates.values().iterator().next();
+if (bestCandidates.size() == 1) {
+return bestCandidates.get(0);
+}
+
+final String target = methodName + 
Arrays.stream(parameterTypes).map(String::valueOf).collect(Collectors.joining(",",
 "(", ")"));
+final String strCandidates = 
bestCandidates.stream().map(Method::toString).collect(Collectors.joining("\n  
"));
+throw new IllegalStateException("Found multiple candidates for method 
" + target + " on class " + cls + ":\n  " + strCandidates);

Review comment:
   Let's not hard-code Linux-specific new-line chars in error messages, 
but, if you really want new-lines, use `%n` with `String.format()`.

##
File path: src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
##
@@ -742,35 +745,51 @@ public static Method getMatchingMethod(final Class 
cls, final String methodNa
 Validate.notNull(cls, "cls");
 Validate.notEmpty(methodName, "methodName");
 
-// Address methods in superclasses
-Method[] methodArray = cls.getDeclaredMethods();
-final List> superclassList = 
ClassUtils.getAllSuperclasses(cls);
-for (final Class klass : superclassList) {
-methodArray = ArrayUtils.addAll(methodArray, 
klass.getDeclaredMethods());
-}
+final List methods = Arrays.stream(cls.getDeclaredMethods())
+.filter(method -> method.getName().equals(methodName))
+.collect(toList());
+
+ClassUtils.getAllSuperclasses(cls).stream()
+.map(Class::getDeclaredMethods)
+.flatMap(Arrays::stream)
+.filter(method -> method.getName().equals(methodName))
+.forEach(methods::add);
 
-Method inexactMatch = null;
-for (final Method method : methodArray) {
-if (methodName.equals(method.getName()) 

[jira] [Work logged] (LANG-1544) MethodUtils.invokeMethod NullPointerException in case of null in args list

2020-12-22 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1544?focusedWorklogId=527229=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-527229
 ]

ASF GitHub Bot logged work on LANG-1544:


Author: ASF GitHub Bot
Created on: 22/Dec/20 15:03
Start Date: 22/Dec/20 15:03
Worklog Time Spent: 10m 
  Work Description: garydgregory commented on pull request #680:
URL: https://github.com/apache/commons-lang/pull/680#issuecomment-749585160


   https://issues.apache.org/jira/browse/LANG-1544



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:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 527229)
Time Spent: 2.5h  (was: 2h 20m)

> MethodUtils.invokeMethod NullPointerException in case of null in args list
> --
>
> Key: LANG-1544
> URL: https://issues.apache.org/jira/browse/LANG-1544
> Project: Commons Lang
>  Issue Type: Bug
>  Components: lang.reflect.*
>Affects Versions: 3.10
>Reporter: Peter Nagy
>Priority: Critical
>  Time Spent: 2.5h
>  Remaining Estimate: 0h
>
> MethodUtils:774
>  
> if (classArray[offset].equals(toClassArray[offset])) {
>  continue;
> } else if (ClassUtils.isAssignable(classArray[offset], toClassArray[offset], 
> true)
>  
> cause NPE if classArray[offset] is null. Can you please extend the if 
> condition with a null check, like this?
>  
> if (classArray[offset] != null && 
> classArray[offset].equals(toClassArray[offset]))



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (LANG-1544) MethodUtils.invokeMethod NullPointerException in case of null in args list

2020-12-21 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1544?focusedWorklogId=526980=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-526980
 ]

ASF GitHub Bot logged work on LANG-1544:


Author: ASF GitHub Bot
Created on: 21/Dec/20 22:03
Start Date: 21/Dec/20 22:03
Worklog Time Spent: 10m 
  Work Description: coveralls commented on pull request #680:
URL: https://github.com/apache/commons-lang/pull/680#issuecomment-749221904


   
   [![Coverage 
Status](https://coveralls.io/builds/35875621/badge)](https://coveralls.io/builds/35875621)
   
   Coverage increased (+0.003%) to 95.019% when pulling 
**8bb3703f828c61b891e5cb79c34f572051f958ff on 
mdbuck77:LANG-1544_MethodUtils_Throws_NPE** into 
**c9e825e823e30c5b1e3ddc9de5e8fd0094d52ee5 on apache:master**.
   



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:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 526980)
Time Spent: 2h 20m  (was: 2h 10m)

> MethodUtils.invokeMethod NullPointerException in case of null in args list
> --
>
> Key: LANG-1544
> URL: https://issues.apache.org/jira/browse/LANG-1544
> Project: Commons Lang
>  Issue Type: Bug
>  Components: lang.reflect.*
>Affects Versions: 3.10
>Reporter: Peter Nagy
>Priority: Critical
>  Time Spent: 2h 20m
>  Remaining Estimate: 0h
>
> MethodUtils:774
>  
> if (classArray[offset].equals(toClassArray[offset])) {
>  continue;
> } else if (ClassUtils.isAssignable(classArray[offset], toClassArray[offset], 
> true)
>  
> cause NPE if classArray[offset] is null. Can you please extend the if 
> condition with a null check, like this?
>  
> if (classArray[offset] != null && 
> classArray[offset].equals(toClassArray[offset]))



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (LANG-1544) MethodUtils.invokeMethod NullPointerException in case of null in args list

2020-12-21 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1544?focusedWorklogId=526963=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-526963
 ]

ASF GitHub Bot logged work on LANG-1544:


Author: ASF GitHub Bot
Created on: 21/Dec/20 21:28
Start Date: 21/Dec/20 21:28
Worklog Time Spent: 10m 
  Work Description: mdbuck77 opened a new pull request #680:
URL: https://github.com/apache/commons-lang/pull/680


   - Null guards in place to handle one or more nulls specified as one of the 
parameters of the method to invoke.
   - Check for an exact match of the actual parameter types against all of the 
methods on the class. This prevents picking an "upcasted" method (i.e. int 
specified but a method with a double is chosen).
   - Throw an IllegalStateException with a helpful message if multiple 
candidate methods were found. This happens when multiple Methods had the same 
"distance" from the desired parameter types. Before this change the algorithm 
would just chose the first one.
   - Tests for the above.



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:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 526963)
Time Spent: 2h 10m  (was: 2h)

> MethodUtils.invokeMethod NullPointerException in case of null in args list
> --
>
> Key: LANG-1544
> URL: https://issues.apache.org/jira/browse/LANG-1544
> Project: Commons Lang
>  Issue Type: Bug
>  Components: lang.reflect.*
>Affects Versions: 3.10
>Reporter: Peter Nagy
>Priority: Critical
>  Time Spent: 2h 10m
>  Remaining Estimate: 0h
>
> MethodUtils:774
>  
> if (classArray[offset].equals(toClassArray[offset])) {
>  continue;
> } else if (ClassUtils.isAssignable(classArray[offset], toClassArray[offset], 
> true)
>  
> cause NPE if classArray[offset] is null. Can you please extend the if 
> condition with a null check, like this?
>  
> if (classArray[offset] != null && 
> classArray[offset].equals(toClassArray[offset]))



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (LANG-1544) MethodUtils.invokeMethod NullPointerException in case of null in args list

2020-11-13 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1544?focusedWorklogId=511254=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-511254
 ]

ASF GitHub Bot logged work on LANG-1544:


Author: ASF GitHub Bot
Created on: 13/Nov/20 08:16
Start Date: 13/Nov/20 08:16
Worklog Time Spent: 10m 
  Work Description: pixelr commented on pull request #583:
URL: https://github.com/apache/commons-lang/pull/583#issuecomment-726595412


   closing. Please re-open if need. Thanks for reviewing :)



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:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 511254)
Time Spent: 1h 50m  (was: 1h 40m)

> MethodUtils.invokeMethod NullPointerException in case of null in args list
> --
>
> Key: LANG-1544
> URL: https://issues.apache.org/jira/browse/LANG-1544
> Project: Commons Lang
>  Issue Type: Bug
>  Components: lang.reflect.*
>Affects Versions: 3.10
>Reporter: Peter Nagy
>Priority: Critical
>  Time Spent: 1h 50m
>  Remaining Estimate: 0h
>
> MethodUtils:774
>  
> if (classArray[offset].equals(toClassArray[offset])) {
>  continue;
> } else if (ClassUtils.isAssignable(classArray[offset], toClassArray[offset], 
> true)
>  
> cause NPE if classArray[offset] is null. Can you please extend the if 
> condition with a null check, like this?
>  
> if (classArray[offset] != null && 
> classArray[offset].equals(toClassArray[offset]))



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (LANG-1544) MethodUtils.invokeMethod NullPointerException in case of null in args list

2020-11-13 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1544?focusedWorklogId=511255=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-511255
 ]

ASF GitHub Bot logged work on LANG-1544:


Author: ASF GitHub Bot
Created on: 13/Nov/20 08:16
Start Date: 13/Nov/20 08:16
Worklog Time Spent: 10m 
  Work Description: pixelr closed pull request #583:
URL: https://github.com/apache/commons-lang/pull/583


   



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:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 511255)
Time Spent: 2h  (was: 1h 50m)

> MethodUtils.invokeMethod NullPointerException in case of null in args list
> --
>
> Key: LANG-1544
> URL: https://issues.apache.org/jira/browse/LANG-1544
> Project: Commons Lang
>  Issue Type: Bug
>  Components: lang.reflect.*
>Affects Versions: 3.10
>Reporter: Peter Nagy
>Priority: Critical
>  Time Spent: 2h
>  Remaining Estimate: 0h
>
> MethodUtils:774
>  
> if (classArray[offset].equals(toClassArray[offset])) {
>  continue;
> } else if (ClassUtils.isAssignable(classArray[offset], toClassArray[offset], 
> true)
>  
> cause NPE if classArray[offset] is null. Can you please extend the if 
> condition with a null check, like this?
>  
> if (classArray[offset] != null && 
> classArray[offset].equals(toClassArray[offset]))



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (LANG-1544) MethodUtils.invokeMethod NullPointerException in case of null in args list

2020-10-05 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1544?focusedWorklogId=495712=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-495712
 ]

ASF GitHub Bot logged work on LANG-1544:


Author: ASF GitHub Bot
Created on: 06/Oct/20 04:27
Start Date: 06/Oct/20 04:27
Worklog Time Spent: 10m 
  Work Description: pixelr edited a comment on pull request #583:
URL: https://github.com/apache/commons-lang/pull/583#issuecomment-704019436


   > Hi @pixelr
   > 
   > After looking again, I'm not sure this PR makes sense. The test you 
patched calls a private method, and this private method is not going to be 
called with just any value. In this case, the private method `distance` is only 
called from `MethodUtils.getMatchingMethod(Class, String, Class...)` 
where our `getMatchingMethod` calls 
`java.lang.reflect.Method.getParameterTypes()`.
   > 
   > Do you have a case where 
`java.lang.reflect.Method.getParameterTypes()`returns an array containing a 
null? Can you show this by calling a public method like 
`org.apache.commons.lang3.reflect.MethodUtils.getMatchingMethod(Class, 
String, Class...)`?
   > 
   > Otherwise, this PR just make the `distance` method more complicated than 
it has to be, granted not by much, but there would then be no sense if making 
the whole code base more NPE proof where it does not need to be.
   > 
   > Let us know your findings.
   
   you are right. I don't think complicating code would be right. I have asked 
bug reporter for further info else will close the PR. Apologies about very 
delayed reply
   



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:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 495712)
Time Spent: 1h 40m  (was: 1.5h)

> MethodUtils.invokeMethod NullPointerException in case of null in args list
> --
>
> Key: LANG-1544
> URL: https://issues.apache.org/jira/browse/LANG-1544
> Project: Commons Lang
>  Issue Type: Bug
>  Components: lang.reflect.*
>Affects Versions: 3.10
>Reporter: Peter Nagy
>Priority: Critical
>  Time Spent: 1h 40m
>  Remaining Estimate: 0h
>
> MethodUtils:774
>  
> if (classArray[offset].equals(toClassArray[offset])) {
>  continue;
> } else if (ClassUtils.isAssignable(classArray[offset], toClassArray[offset], 
> true)
>  
> cause NPE if classArray[offset] is null. Can you please extend the if 
> condition with a null check, like this?
>  
> if (classArray[offset] != null && 
> classArray[offset].equals(toClassArray[offset]))



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (LANG-1544) MethodUtils.invokeMethod NullPointerException in case of null in args list

2020-10-05 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1544?focusedWorklogId=495711=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-495711
 ]

ASF GitHub Bot logged work on LANG-1544:


Author: ASF GitHub Bot
Created on: 06/Oct/20 04:26
Start Date: 06/Oct/20 04:26
Worklog Time Spent: 10m 
  Work Description: pixelr commented on pull request #583:
URL: https://github.com/apache/commons-lang/pull/583#issuecomment-704019436


   > Hi @pixelr
   > 
   > After looking again, I'm not sure this PR makes sense. The test you 
patched calls a private method, and this private method is not going to be 
called with just any value. In this case, the private method `distance` is only 
called from `MethodUtils.getMatchingMethod(Class, String, Class...)` 
where our `getMatchingMethod` calls 
`java.lang.reflect.Method.getParameterTypes()`.
   > 
   > Do you have a case where 
`java.lang.reflect.Method.getParameterTypes()`returns an array containing a 
null? Can you show this by calling a public method like 
`org.apache.commons.lang3.reflect.MethodUtils.getMatchingMethod(Class, 
String, Class...)`?
   > 
   > Otherwise, this PR just make the `distance` method more complicated than 
it has to be, granted not by much, but there would then be no sense if making 
the whole code base more NPE proof where it does not need to be.
   > 
   > Let us know your findings.
   you are right. I don't think complicating code would be right. I have asked 
bug reporter for further info else will close the PR.
   



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:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 495711)
Time Spent: 1.5h  (was: 1h 20m)

> MethodUtils.invokeMethod NullPointerException in case of null in args list
> --
>
> Key: LANG-1544
> URL: https://issues.apache.org/jira/browse/LANG-1544
> Project: Commons Lang
>  Issue Type: Bug
>  Components: lang.reflect.*
>Affects Versions: 3.10
>Reporter: Peter Nagy
>Priority: Critical
>  Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> MethodUtils:774
>  
> if (classArray[offset].equals(toClassArray[offset])) {
>  continue;
> } else if (ClassUtils.isAssignable(classArray[offset], toClassArray[offset], 
> true)
>  
> cause NPE if classArray[offset] is null. Can you please extend the if 
> condition with a null check, like this?
>  
> if (classArray[offset] != null && 
> classArray[offset].equals(toClassArray[offset]))



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (LANG-1544) MethodUtils.invokeMethod NullPointerException in case of null in args list

2020-10-05 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1544?focusedWorklogId=495710=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-495710
 ]

ASF GitHub Bot logged work on LANG-1544:


Author: ASF GitHub Bot
Created on: 06/Oct/20 04:25
Start Date: 06/Oct/20 04:25
Worklog Time Spent: 10m 
  Work Description: pixelr commented on pull request #583:
URL: https://github.com/apache/commons-lang/pull/583#issuecomment-704019077


   > Is there example user-side codes which can lead to NPE before this pr?
   
   @XenoAmess I took this a first good issue to fix. But, when I tried 
reproducing it, I am not able to do so. I have asked the reporter on JIRA for 
info on this. If we don't find a real use case, will close the PR



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:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 495710)
Time Spent: 1h 20m  (was: 1h 10m)

> MethodUtils.invokeMethod NullPointerException in case of null in args list
> --
>
> Key: LANG-1544
> URL: https://issues.apache.org/jira/browse/LANG-1544
> Project: Commons Lang
>  Issue Type: Bug
>  Components: lang.reflect.*
>Affects Versions: 3.10
>Reporter: Peter Nagy
>Priority: Critical
>  Time Spent: 1h 20m
>  Remaining Estimate: 0h
>
> MethodUtils:774
>  
> if (classArray[offset].equals(toClassArray[offset])) {
>  continue;
> } else if (ClassUtils.isAssignable(classArray[offset], toClassArray[offset], 
> true)
>  
> cause NPE if classArray[offset] is null. Can you please extend the if 
> condition with a null check, like this?
>  
> if (classArray[offset] != null && 
> classArray[offset].equals(toClassArray[offset]))



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (LANG-1544) MethodUtils.invokeMethod NullPointerException in case of null in args list

2020-07-20 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1544?focusedWorklogId=461191=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-461191
 ]

ASF GitHub Bot logged work on LANG-1544:


Author: ASF GitHub Bot
Created on: 20/Jul/20 17:54
Start Date: 20/Jul/20 17:54
Worklog Time Spent: 10m 
  Work Description: garydgregory commented on pull request #583:
URL: https://github.com/apache/commons-lang/pull/583#issuecomment-661241475


   Hi @pixelr 
   
   After looking again, I'm not sure this PR makes sense. The test you patched 
calls a private method, and this private method is not going to be called with 
just any value. In this case, the private method `distance` is only called from 
`MethodUtils.getMatchingMethod(Class, String, Class...)` where our 
`getMatchingMethod` calls `java.lang.reflect.Method.getParameterTypes()`. 
   
   Do you have a case where 
`java.lang.reflect.Method.getParameterTypes()`returns an array containing a 
null? Can you show this by calling a public method like 
`org.apache.commons.lang3.reflect.MethodUtils.getMatchingMethod(Class, 
String, Class...)`?
   
   Otherwise, this PR just make the `distance` method more complicated than it 
has to be, granted not by much, but there would then be no sense if making the 
whole code base more NPE proof where it does not need to be.
   
   Let us know your findings.



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:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 461191)
Time Spent: 1h 10m  (was: 1h)

> MethodUtils.invokeMethod NullPointerException in case of null in args list
> --
>
> Key: LANG-1544
> URL: https://issues.apache.org/jira/browse/LANG-1544
> Project: Commons Lang
>  Issue Type: Bug
>  Components: lang.reflect.*
>Affects Versions: 3.10
>Reporter: Peter Nagy
>Priority: Critical
>  Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> MethodUtils:774
>  
> if (classArray[offset].equals(toClassArray[offset])) {
>  continue;
> } else if (ClassUtils.isAssignable(classArray[offset], toClassArray[offset], 
> true)
>  
> cause NPE if classArray[offset] is null. Can you please extend the if 
> condition with a null check, like this?
>  
> if (classArray[offset] != null && 
> classArray[offset].equals(toClassArray[offset]))



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (LANG-1544) MethodUtils.invokeMethod NullPointerException in case of null in args list

2020-07-20 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1544?focusedWorklogId=460971=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-460971
 ]

ASF GitHub Bot logged work on LANG-1544:


Author: ASF GitHub Bot
Created on: 20/Jul/20 09:06
Start Date: 20/Jul/20 09:06
Worklog Time Spent: 10m 
  Work Description: pixelr commented on a change in pull request #583:
URL: https://github.com/apache/commons-lang/pull/583#discussion_r457201283



##
File path: src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
##
@@ -782,7 +782,7 @@ private static int distance(final Class[] classArray, 
final Class[] toClas
 }
 for (int offset = 0; offset < classArray.length; offset++) {
 // Note InheritanceUtils.distance() uses different scoring system.
-if (classArray[offset].equals(toClassArray[offset])) {
+if (Objects.isNull(classArray[offset]) || 
classArray[offset].equals(toClassArray[offset])) {

Review comment:
   @garydgregory Please review and merge if changes are correct





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:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 460971)
Time Spent: 1h  (was: 50m)

> MethodUtils.invokeMethod NullPointerException in case of null in args list
> --
>
> Key: LANG-1544
> URL: https://issues.apache.org/jira/browse/LANG-1544
> Project: Commons Lang
>  Issue Type: Bug
>  Components: lang.reflect.*
>Affects Versions: 3.10
>Reporter: Peter Nagy
>Priority: Critical
>  Time Spent: 1h
>  Remaining Estimate: 0h
>
> MethodUtils:774
>  
> if (classArray[offset].equals(toClassArray[offset])) {
>  continue;
> } else if (ClassUtils.isAssignable(classArray[offset], toClassArray[offset], 
> true)
>  
> cause NPE if classArray[offset] is null. Can you please extend the if 
> condition with a null check, like this?
>  
> if (classArray[offset] != null && 
> classArray[offset].equals(toClassArray[offset]))



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (LANG-1544) MethodUtils.invokeMethod NullPointerException in case of null in args list

2020-07-19 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1544?focusedWorklogId=460796=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-460796
 ]

ASF GitHub Bot logged work on LANG-1544:


Author: ASF GitHub Bot
Created on: 19/Jul/20 07:38
Start Date: 19/Jul/20 07:38
Worklog Time Spent: 10m 
  Work Description: coveralls edited a comment on pull request #583:
URL: https://github.com/apache/commons-lang/pull/583#issuecomment-660543925







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:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 460796)
Time Spent: 50m  (was: 40m)

> MethodUtils.invokeMethod NullPointerException in case of null in args list
> --
>
> Key: LANG-1544
> URL: https://issues.apache.org/jira/browse/LANG-1544
> Project: Commons Lang
>  Issue Type: Bug
>  Components: lang.reflect.*
>Affects Versions: 3.10
>Reporter: Peter Nagy
>Priority: Critical
>  Time Spent: 50m
>  Remaining Estimate: 0h
>
> MethodUtils:774
>  
> if (classArray[offset].equals(toClassArray[offset])) {
>  continue;
> } else if (ClassUtils.isAssignable(classArray[offset], toClassArray[offset], 
> true)
>  
> cause NPE if classArray[offset] is null. Can you please extend the if 
> condition with a null check, like this?
>  
> if (classArray[offset] != null && 
> classArray[offset].equals(toClassArray[offset]))



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (LANG-1544) MethodUtils.invokeMethod NullPointerException in case of null in args list

2020-07-19 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1544?focusedWorklogId=460793=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-460793
 ]

ASF GitHub Bot logged work on LANG-1544:


Author: ASF GitHub Bot
Created on: 19/Jul/20 07:30
Start Date: 19/Jul/20 07:30
Worklog Time Spent: 10m 
  Work Description: pixelr commented on a change in pull request #583:
URL: https://github.com/apache/commons-lang/pull/583#discussion_r456873203



##
File path: src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
##
@@ -782,7 +782,7 @@ private static int distance(final Class[] classArray, 
final Class[] toClas
 }
 for (int offset = 0; offset < classArray.length; offset++) {
 // Note InheritanceUtils.distance() uses different scoring system.
-if (classArray[offset].equals(toClassArray[offset])) {
+if (Objects.isNull(classArray[offset]) || 
classArray[offset].equals(toClassArray[offset])) {

Review comment:
   I have update the commit with suggested changes. Please have a look. 
thanks !

##
File path: src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
##
@@ -782,7 +782,7 @@ private static int distance(final Class[] classArray, 
final Class[] toClas
 }
 for (int offset = 0; offset < classArray.length; offset++) {
 // Note InheritanceUtils.distance() uses different scoring system.
-if (classArray[offset].equals(toClassArray[offset])) {
+if (Objects.isNull(classArray[offset]) || 
classArray[offset].equals(toClassArray[offset])) {

Review comment:
   I have updated the commit with suggested changes. Please have a look. 
thanks !





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:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 460793)
Time Spent: 40m  (was: 0.5h)

> MethodUtils.invokeMethod NullPointerException in case of null in args list
> --
>
> Key: LANG-1544
> URL: https://issues.apache.org/jira/browse/LANG-1544
> Project: Commons Lang
>  Issue Type: Bug
>  Components: lang.reflect.*
>Affects Versions: 3.10
>Reporter: Peter Nagy
>Priority: Critical
>  Time Spent: 40m
>  Remaining Estimate: 0h
>
> MethodUtils:774
>  
> if (classArray[offset].equals(toClassArray[offset])) {
>  continue;
> } else if (ClassUtils.isAssignable(classArray[offset], toClassArray[offset], 
> true)
>  
> cause NPE if classArray[offset] is null. Can you please extend the if 
> condition with a null check, like this?
>  
> if (classArray[offset] != null && 
> classArray[offset].equals(toClassArray[offset]))



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (LANG-1544) MethodUtils.invokeMethod NullPointerException in case of null in args list

2020-07-18 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1544?focusedWorklogId=460755=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-460755
 ]

ASF GitHub Bot logged work on LANG-1544:


Author: ASF GitHub Bot
Created on: 18/Jul/20 21:41
Start Date: 18/Jul/20 21:41
Worklog Time Spent: 10m 
  Work Description: garydgregory commented on a change in pull request #583:
URL: https://github.com/apache/commons-lang/pull/583#discussion_r456830635



##
File path: src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
##
@@ -782,7 +782,7 @@ private static int distance(final Class[] classArray, 
final Class[] toClas
 }
 for (int offset = 0; offset < classArray.length; offset++) {
 // Note InheritanceUtils.distance() uses different scoring system.
-if (classArray[offset].equals(toClassArray[offset])) {
+if (Objects.isNull(classArray[offset]) || 
classArray[offset].equals(toClassArray[offset])) {

Review comment:
   Objects#isNull is meant to be used with lambdas, use a `==` test here 
instead.





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:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 460755)
Time Spent: 0.5h  (was: 20m)

> MethodUtils.invokeMethod NullPointerException in case of null in args list
> --
>
> Key: LANG-1544
> URL: https://issues.apache.org/jira/browse/LANG-1544
> Project: Commons Lang
>  Issue Type: Bug
>  Components: lang.reflect.*
>Affects Versions: 3.10
>Reporter: Peter Nagy
>Priority: Critical
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> MethodUtils:774
>  
> if (classArray[offset].equals(toClassArray[offset])) {
>  continue;
> } else if (ClassUtils.isAssignable(classArray[offset], toClassArray[offset], 
> true)
>  
> cause NPE if classArray[offset] is null. Can you please extend the if 
> condition with a null check, like this?
>  
> if (classArray[offset] != null && 
> classArray[offset].equals(toClassArray[offset]))



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (LANG-1544) MethodUtils.invokeMethod NullPointerException in case of null in args list

2020-07-18 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1544?focusedWorklogId=460753=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-460753
 ]

ASF GitHub Bot logged work on LANG-1544:


Author: ASF GitHub Bot
Created on: 18/Jul/20 21:18
Start Date: 18/Jul/20 21:18
Worklog Time Spent: 10m 
  Work Description: coveralls commented on pull request #583:
URL: https://github.com/apache/commons-lang/pull/583#issuecomment-660543925


   
   [![Coverage 
Status](https://coveralls.io/builds/32167532/badge)](https://coveralls.io/builds/32167532)
   
   Coverage decreased (-0.006%) to 94.657% when pulling 
**ece3edaf0d355447466d3eafe24436f4f4c3 on 
pixelr:LANG-1544-NPEFixMethodUtils** into 
**031c1d0b8c5c183cda8de2cf20cbd3a2ae662dc7 on apache:master**.
   



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:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 460753)
Time Spent: 20m  (was: 10m)

> MethodUtils.invokeMethod NullPointerException in case of null in args list
> --
>
> Key: LANG-1544
> URL: https://issues.apache.org/jira/browse/LANG-1544
> Project: Commons Lang
>  Issue Type: Bug
>  Components: lang.reflect.*
>Affects Versions: 3.10
>Reporter: Peter Nagy
>Priority: Critical
>  Time Spent: 20m
>  Remaining Estimate: 0h
>
> MethodUtils:774
>  
> if (classArray[offset].equals(toClassArray[offset])) {
>  continue;
> } else if (ClassUtils.isAssignable(classArray[offset], toClassArray[offset], 
> true)
>  
> cause NPE if classArray[offset] is null. Can you please extend the if 
> condition with a null check, like this?
>  
> if (classArray[offset] != null && 
> classArray[offset].equals(toClassArray[offset]))



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (LANG-1544) MethodUtils.invokeMethod NullPointerException in case of null in args list

2020-07-18 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1544?focusedWorklogId=460751=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-460751
 ]

ASF GitHub Bot logged work on LANG-1544:


Author: ASF GitHub Bot
Created on: 18/Jul/20 21:06
Start Date: 18/Jul/20 21:06
Worklog Time Spent: 10m 
  Work Description: pixelr opened a new pull request #583:
URL: https://github.com/apache/commons-lang/pull/583


   This Pull request fixed Null Pointer Exception in the 
   MethodUtils:774 :  NPE when classArray[offset] is null



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:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 460751)
Remaining Estimate: 0h
Time Spent: 10m

> MethodUtils.invokeMethod NullPointerException in case of null in args list
> --
>
> Key: LANG-1544
> URL: https://issues.apache.org/jira/browse/LANG-1544
> Project: Commons Lang
>  Issue Type: Bug
>  Components: lang.reflect.*
>Affects Versions: 3.10
>Reporter: Peter Nagy
>Priority: Critical
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> MethodUtils:774
>  
> if (classArray[offset].equals(toClassArray[offset])) {
>  continue;
> } else if (ClassUtils.isAssignable(classArray[offset], toClassArray[offset], 
> true)
>  
> cause NPE if classArray[offset] is null. Can you please extend the if 
> condition with a null check, like this?
>  
> if (classArray[offset] != null && 
> classArray[offset].equals(toClassArray[offset]))



--
This message was sent by Atlassian Jira
(v8.3.4#803005)