You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2019/02/20 10:24:00 UTC

[jira] [Work logged] (LANG-1433) MethodUtils will throw a NPE if invokeMethod() is called for a var-args method

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

ASF GitHub Bot logged work on LANG-1433:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 20/Feb/19 10:23
            Start Date: 20/Feb/19 10:23
    Worklog Time Spent: 10m 
      Work Description: cfranzen commented on pull request #407: LANG-1433: MethodUtils will throw a NPE if invokeMethod() is called for a var-args method
URL: https://github.com/apache/commons-lang/pull/407
 
 
   
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


Issue Time Tracking
-------------------

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

> MethodUtils will throw a NPE if invokeMethod() is called for a var-args method
> ------------------------------------------------------------------------------
>
>                 Key: LANG-1433
>                 URL: https://issues.apache.org/jira/browse/LANG-1433
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.reflect.*
>    Affects Versions: 3.8.1
>            Reporter: Christian Franzen
>            Priority: Major
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Whenever calling a var-args method using invokeMethod() of MethodUtils it will throw a NPE if the last parameter value is null. 
> Example: Given is the following class with var-args method
> {code:java}
> public class MyClass {
>    public String myMethod(final String... args) {
>       ...
>    }
>    public String myMethod(final Integer... args) {
>       ...
>    }
> }
> {code}
> The following code will work:
> {code:java}
> MethodUtils.invokeMethod(myObject, "myMethod", "a", null, "c");
> {code}
> But this will throw a NPE:
> {code:java}
> MethodUtils.invokeMethod(myObject, "myMethod", "a", "b", null);
> {code}
> Further more it is not deterministic which method of the two will be called if the method search of invokeMethod() can not find a single unique match. So the code
> {code:java}
> MethodUtils.invokeMethod(myObject, "myMethod", new Object[] {null});
> {code}
> might call any of the two methods of MyClass and it might change with each and every invocation. The search is not deterministic due to Class.getMethods () is not deterministic.
> I would categorize such a method call as a bug, due to it should not be the intention of the developer to just pick any of the methods. However, debugging such an issue is really hard if the "right" method is called "sometimes" and it can be solved by just doing a sort, which should be no big deal I belive.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)