> On 10/12/2017, at 4:24 PM, Nitkalya Wiriyanuparb (Ing) <dekpi...@gmail.com> 
> wrote:
> 
> On 9 Dec 2017, 3:35 AM +1300, Mark Thomas <ma...@apache.org>, wrote:
> 
>> On 07/12/17 15:00, Mark Thomas wrote:
>>> On 07/12/17 02:52, Nitkalya (Ing) Wiriyanuparb wrote:
>>>> Hello.
>>>> 
>>>> I'm upgrading from Tomcat 7.0.30 to 8.5.24. Everything is working fine, but
>>>> I notice that BeanELResolver behaves differently when calling a bean
>>>> varargs method with no argument.
>>>> 
>>>> My action bean has a method with the signature "public String
>>>> getIncludes(final String... moduleNames)". I'm calling it on one of my JSP
>>>> pages like "${actionBean.getIncludes()}", but got MethodNotFoundException.
>>>> Calling it with some arguments or an empty array would work – as one would
>>>> expect. Please see the stacktrace below.
>>>> 
>>>> This method call used to be okay in 7.0.30. I've tried to find something in
>>>> the EL and JSP specifications around varargs, but couldn't find anything
>>>> concrete. I got the impression that it's not officially supported in the
>>>> specs, but Tomcat supports it.
>>>> 
>>>> I'm treating it as a bug as I've already created a patch for it – see
>>>> below. However, I'm new to this mailing list so I thought I would ask 
>>>> first.
>>>> 
>>>> Is this a bug?
>>> 
>>> It looks like it, yes.
>>> 
>>> Thanks for the patch. Note it is usually best to attach patches to a
>>> Bugzilla issue as that prevents them from getting mangled by e-mail clients.
>>> 
>>> I'll take a closer look at this now.
>> 
>> Thanks again for reporting the issue and providing a patch.
>> 
>> I've applied your patch with a few changes and additions.
>> 
>> The provided test cases highlighted the complexity of matching varargs
>> methods, particularly because of the coercion rules that apply in EL. I
>> expanded the tests significantly to try and cover all the edge cases. I
>> extended the proposed patch to cover those edge cases as well.
>> 
>> The changes will are in:
>> - trunk for 9.0.3 onwards
>> - 8.5.x for 8.5.25 onwards
>> - 8.0.x for 8.0.49 onwards
>> 
>> Mark
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
>> For additional commands, e-mail: users-h...@tomcat.apache.org
>> 
> 
> Thanks for the quick fix. I’ll be testing it with my system tomorrow.
> 
> I think there might be another edge case that we missed i.e. passing an array 
> as a varargs. If I remember correctly the array is currently coerced into a 
> string. Its string representation becomes the first element of the varargs 
> instead of the array being the varargs itself. I could be wrong though – will 
> double check tomorrow and report back again. However, I have no use case for 
> this edge case if it’s deemed ‘unsupported’.
> 
> Cheers,
> Ing

Tested with my system – everything’s awesome. I can also confirm that the edge 
case I mentioned is valid; calling the varargs method with an array 
${actionBean.getIncludes([“something"])} doesn’t coerce correctly. I personally 
don’t care about this use case, so I’ll leave it to the maintainers to decide. 
:)

Cheers
Ing

Reply via email to