commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henri Biestro (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (JEXL-281) MethodExecutor incorrectly tests for empty parameters list
Date Tue, 18 Dec 2018 10:19:00 GMT

    [ https://issues.apache.org/jira/browse/JEXL-281?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16723093#comment-16723093
] 

Henri Biestro edited comment on JEXL-281 at 12/18/18 10:18 AM:
---------------------------------------------------------------

- releases notes and changes
https://github.com/apache/commons-jexl/commit/51a58ed28ce0a530c7854aa863849e47de294356
revision   : e7d212e423cd409bdd049864e77b0521ea5e4c10


was (Author: henrib):
- releases notes and changes
revision   : e7d212e423cd409bdd049864e77b0521ea5e4c10

> MethodExecutor incorrectly tests for empty parameters list
> ----------------------------------------------------------
>
>                 Key: JEXL-281
>                 URL: https://issues.apache.org/jira/browse/JEXL-281
>             Project: Commons JEXL
>          Issue Type: Bug
>    Affects Versions: 3.1
>            Reporter: Mirek Hankus
>            Assignee: Henri Biestro
>            Priority: Major
>             Fix For: 3.2
>
>
> Currently MethodExecutor constructor contains code 
> {code:java}
> if (method != null) {
>     Class<?>[] formal = method.getParameterTypes();
>     // if the last parameter is an array, the method is considered as vararg
>     if (formal != null && MethodKey.isVarArgs(method)) {
>         vastart = formal.length - 1;
>         vaclass = formal[vastart].getComponentType();
>     }
> }{code}
> variable formal is never null, beacause Javadoc for getParameterTypes  states that 
"returns an array of length 0 if the underlying executable takes no parameters." (implementation
invokes  clone - so there always be an object)
> So test for empty parameter list  should not test for null, but for empty array - 
> {code:java}
> if (formal.length > 0 && MethodKey.isVarArgs(method)) {{code}
> .
> Problem is that MethodKey.isVarArgs is very costly (it traverses class hierarchy, and
throws Exception for every object which does not have method by this name) - so invocation
of isVarArgs should be avoided if not required. Currently it is always called due to wrong
test condition
>  
>  
>  



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

Mime
View raw message