[jira] [Comment Edited] (LANG-1544) MethodUtils.invokeMethod NullPointerException in case of null in args list
[ https://issues.apache.org/jira/browse/LANG-1544?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17253559#comment-17253559 ] Gary D. Gregory edited comment on LANG-1544 at 12/22/20, 3:13 PM: -- The description needs a stack trace to make it easier for everyone to match up with exceptions seen in the wild. was (Author: garydgregory): The description needs a stack trace to make it easier for everyone to match up with exceptions in the wild. > 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] [Comment Edited] (LANG-1544) MethodUtils.invokeMethod NullPointerException in case of null in args list
[ https://issues.apache.org/jira/browse/LANG-1544?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17253134#comment-17253134 ] Michael Buck edited comment on LANG-1544 at 12/21/20, 9:51 PM: --- The issue seems to manifest itself when MethodUtils#getMatchingMethod() is called with one or more of the incoming parameterTypes as null and the target class to find the method has more than one method that is a possible candidate. This causes the private distance method to be invoked which causes the NPE. Please see PR [here|https://github.com/apache/commons-lang/pull/680] was (Author: mdbuck77): The issue seems to manifest itself when MethodUtils#getMatchingMethod() is called with one or more of the incoming parameterTypes as null and the target class to find the method has more than one method that is a possible candidate. This causes the private distance method to be invoked which causes the NPE. Please see PR [here|[http://example.com|https://github.com/apache/commons-lang/pull/680]]. > 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] [Comment Edited] (LANG-1544) MethodUtils.invokeMethod NullPointerException in case of null in args list
[ https://issues.apache.org/jira/browse/LANG-1544?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17228450#comment-17228450 ] Arturo Bernal edited comment on LANG-1544 at 11/10/20, 8:20 PM: Hi [~RobertBudda] Hi[~ggregory] I have tried to reproduce the error but I can't. {code:java} @Test public void testMethodABG() throws IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException, ClassNotFoundException { Class c = Class.forName("org.apache.commons.lang3.builderClass1"); Object o = c.newInstance(); System.out.println(o); String value = (String) MethodUtils.invokeMethod(o, "testMethod"); System.out.println("Results from getValue: " + value); } class Class1 { public String testMethod() { return "ABG"; } }{code} was (Author: arturobernalg): Hi [~RobertBudda] I have tried to reproduce the error but I can't. {code:java} @Test public void testMethodABG() throws IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException, ClassNotFoundException { Class c = Class.forName("org.apache.commons.lang3.builderClass1"); Object o = c.newInstance(); System.out.println(o); String value = (String) MethodUtils.invokeMethod(o, "testMethod"); System.out.println("Results from getValue: " + value); } class Class1 { public String testMethod() { return "ABG"; } }{code} > 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)