servlet-spec
  1. servlet-spec
  2. SERVLET_SPEC-33

Need to clarify the behavior of HttpServletRequest.getPart/getParts

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None

      Description

      In the javadoc of httpServletRequest.getPart/getParts, it does not mention the behavior of calling these API when there is no @MultipartConfig and multipart-config in deployment descriptors.

      One should exception in this case. UnsupportedOperationException? IllegalStateException?

        Activity

        Hide
        Christian Ludt added a comment -

        Both current javadocs for getPart() and getParts() specify that a ServletException is to be thrown:

        Throws:
        java.io.IOException - if an I/O error occurred during the retrieval [...]
        ServletException - if this request is not of type multipart/form-data
        IllegalStateException - if the request body is larger than maxRequestSize, or any Part in the request is larger than maxFileSize

        Show
        Christian Ludt added a comment - Both current javadocs for getPart() and getParts() specify that a ServletException is to be thrown: Throws: java.io.IOException - if an I/O error occurred during the retrieval [...] ServletException - if this request is not of type multipart/form-data IllegalStateException - if the request body is larger than maxRequestSize, or any Part in the request is larger than maxFileSize
        Hide
        Shing Wai Chan added a comment -

        The ServletException is thrown when the request is not of type multipart/form-data.
        The scenario in the description above is when there is no multipart configuration.
        So, one still need to clarify this case.

        Show
        Shing Wai Chan added a comment - The ServletException is thrown when the request is not of type multipart/form-data. The scenario in the description above is when there is no multipart configuration. So, one still need to clarify this case.
        Hide
        markt_asf added a comment -

        Rather than an Exception, returning null / an empty collection is also an option.

        I prefer IllegalStateException over UnsupportedOperationException but have no string preference between throwing an Exception and returning null / an empty collection.

        Show
        markt_asf added a comment - Rather than an Exception, returning null / an empty collection is also an option. I prefer IllegalStateException over UnsupportedOperationException but have no string preference between throwing an Exception and returning null / an empty collection.
        Hide
        Shing Wai Chan added a comment -

        Sending src/main/java/javax/servlet/http/HttpServletRequest.java
        Transmitting file data .
        Committed revision 55270.

        Show
        Shing Wai Chan added a comment - Sending src/main/java/javax/servlet/http/HttpServletRequest.java Transmitting file data . Committed revision 55270.

          People

          • Assignee:
            Shing Wai Chan
            Reporter:
            Shing Wai Chan
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: