MalformedStreamException after Tomcat Upgrade.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

MalformedStreamException after Tomcat Upgrade.

Srijith Kochunni-2
Hi All,

          This is to seek help on a strange issue that we are observing. We recently did a minor upgrade of Tomcat from 9.0.30 to 9.0.31, in our application, in order to address vulnerability in AJP connector. Ever since then we have started seeing upload failures with our upload servlet when processing large files. Small files do get uploaded, but when we upload large files and we do Multipart file upload, we are randomly and yet consistently seeing that we get the following exception.

[org.apache.commons.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. Stream ended unexpectedly
        at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:351)
        ....
       Caused by: org.apache.commons.fileupload.MultipartStream$MalformedStreamException: Stream ended unexpectedly
        at org.apache.commons.fileupload.MultipartStream$ItemInputStream.makeAvailable(MultipartStream.java:1005)
        at org.apache.commons.fileupload.MultipartStream$ItemInputStream.read(MultipartStream.java:903)
        at java.io.InputStream.read(InputStream.java:101)
        at org.apache.commons.fileupload.util.Streams.copy(Streams.java:100)
        at org.apache.commons.fileupload.util.Streams.copy(Streams.java:70)
        at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:347)

          It appears that the connection is getting reset in the middle of the upload, but the client is very much up and we get PR_CONNECT_RESET_ERROR on the browser.

           My code on the server side is as simple as


            DiskFileItemFactory factory = new DiskFileItemFactory();
            ServletFileUpload fileUpload = new ServletFileUpload(factory);



            List fileItems = fileUpload.parseRequest(originalRequest);





      We would like to know if anyone else has observed this and if there is any way we can debug this further. When I try to attach and debug, the upload however seems to go through fine and is only failing when I am not attached to the process. Any help / suggestions would be much appreciated.



Thanks,

Srijith.