Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-5837

Upload size limit status 500 for files twice bigger than the limit

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.7.11
    • 2.7.12, 3.0.1
    • JAX-RS
    • None
    • Java 7, Tomcat 7

    • Novice

    Description

      I'm using cxf to manage uploads within jax-rs application.
      I used system properties to adjust behaviour on upload in order to limit size to 10MB (10 * 1024 * 1024 = .10 485 760)

      java ....
      -Dorg.apache.cxf.io.CachedOutputStream.Threshold=102400
      -Dorg.apache.cxf.io.CachedOutputStream.OutputDirectory=/temp/upload
      -Dorg.apache.cxf.io.CachedOutputStream.MaxSize=10485760
      ...
      

      This works fine if the user send files a little too big (11MB for exemple) :
      client gets the http status 413.

      But if the sent file is more than twice bigger than the limit (21MB for exemple) it fails :
      client gets the http status 500.

      The reason why seems to be in org.apache.cxf.transport.http.AbstractHTTPDestination#cacheInput.
      In my opinion, before writing the response out, this method is responsible for reading the remains of the request.
      But it does it the same way as when it tried to read attachement file : with size limitations. Because the remaining datas are again bigger than the limit (the file is more than twice too big) have an error.

      Maybe,

      • It would be nice to detect the status 413 (already set for the response).
        So that we could just consume the data (without caching it at all).
      • It would also be nice no to limit this consuming to a multiple of the value "MaxSize" setting, not a hard coded 16MB. See code line 549 : IOUtils.consume(in, 16 * 1024 * 1024)

      Sory,
      I would have liked to submit a pullrequest (or patch) but I've no idea how to find the status code inside the argument (Message outMessage).

      Attachments

        Activity

          People

            sergey_beryozkin Sergey Beryozkin
            sylvain.mougenot Sylvain Mougenot
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: