https://bz.apache.org/bugzilla/show_bug.cgi?id=65358

            Bug ID: 65358
           Summary: Possible EL Bug — Method Matching with Varargs
           Product: Tomcat 9
           Version: 9.0.x
          Hardware: PC
                OS: Mac OS X 10.1
            Status: NEW
          Severity: normal
          Priority: P2
         Component: EL
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: -----

For the following EL expression below, which method should be matched?  

   #{testBean.getMessage(testBean.value1)}.  //  (value1 is a String) 

1) 
    public String getMessage(final EnumInterface enumInstance) {
        return “getMessage(final EnumInterface enumInstance)”;
    }

2) 
    public String getMessage(final String messageKey, final Serializable…
arguments) {
        return “getMessage(final String messageKey, final Serializable…
arguments)”;
    }

Note that TestBean is of type EnumInterface. I’ve provided a reproducible app
with the source on Github. (1)

Prior to the EL varargs patch (2), only the first method was matched. After the
patch, the second method is then matched instead. It seems that first method is
more appropriate rather than the second?

Prior to 9.0.3:
The first method is an assignableMatch. 
The second method (during the wrapper loop) is skipped since the parameter
number check (line 240) evaluated to true.
The first method is therefore the only option available. 

Current Behavior: 
The new varargs checks do not skip the second method this time around. 
Both methods are an assignableMatch, but the second is also a coercibleMatch. 
Therefore, the code selects the second as a better match, from what I gathered? 

I’m a bit stumped. This seems to be a valid scenario, but, then again, maybe
it’s not a bug? I would appreciate any feedback. 

Thank you. 


1) https://github.com/volosied/VarargsELBug

2)
https://github.com/apache/tomcat/commit/b7ce5679b9e6a073dadbc31e6ecde12ad1e0ede8#diff-f5b7c13f66b3d070a6b1c1713ad4b60fd70b26f579a746edc8fe9f19109243b2L240-L244
  -- Added in 9.0.3.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to