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

            Bug ID: 59874
           Summary: ServletRequest.getParameterValues() not according to
                    specs for missing parameters
           Product: Tomcat 8
           Version: 8.0.36
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
          Assignee: [email protected]
          Reporter: [email protected]

The javadoc for ServletRequest.getParameterValues() states:

"Returns an array of String objects containing all of the values the given
request parameter has, or null if the parameter does not exist."

In other words, when a parameter does not exist in the request, this method is
supposed to return null.

Tomcat is returning an empty String array (new String[0]) instead of null.

This nonconformity to the Servlet API causes other software to fail. For
example Spring Framework relies on this method returning null for their
"defaultValue" functionality for "@RequestParam" and this bug causes Spring to
not resolve "defaultValue" correctly.

This issue may also affect Tomcat 9 - please check.


BTW, my personal opinion is that the standard is broken (in this case the
sensible thing to do is to return an empty array, not null), but sometimes you
are forced to implement broken APIs, especially when others rely on the
documented broken behavior.

-- 
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