[ 
https://issues.apache.org/jira/browse/FILEUPLOAD-265?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17202901#comment-17202901
 ] 

Jochen Wiedmann commented on FILEUPLOAD-265:
--------------------------------------------

Okay, quoting from the Bugzilla entry, you mentioned:
{quote}Our (surprising) workaround for now is as follows:. We look at how many 
bytes are expected by request.getContentLength() and if what is read does not 
match the expected size sleep some milli seconds. We do this in a while loop 
which is iterated a maximal number of times or until everything is read. 
Normally this solves the problem. So for example for an upload of 230 K, the 
inputstream claims done after ~130K, after a few ms wait, another 100K appear 
and all works fine.
{quote}
If that claim is true, then there is a problem in Tomcat 9. We simply call 
InputStream.read() (as evidenced in the stack trace, quoted in said Bugzilla 
entry) and the InputStream contract clearly states:

 
{quote} This method blocks until input data is available...
{quote}
 

In other words: We trust in Tomcat to report end-of-file if, and only if, there 
is no more data available, not if "there is no more data available now, but 
there might be in a few milliseconds".

 

Sorry, but we're unable to help here. Please, understand that.

 

 

> .MultipartStream$MalformedStreamException: Stream ended unexpectedly
> --------------------------------------------------------------------
>
>                 Key: FILEUPLOAD-265
>                 URL: https://issues.apache.org/jira/browse/FILEUPLOAD-265
>             Project: Commons FileUpload
>          Issue Type: Bug
>    Affects Versions: 1.3.1
>         Environment: httpclient
>            Reporter: zhumingu
>            Priority: Major
>              Labels: Stream, ended, unexpectedly
>
> When uploading files using the browser,it does not happen.But when submission 
> using tools with 'multipart/form-data',for example httpclient,advanced rest 
> client and so on,
> Only submit a text field, file field is empty, it will report the following 
> exception:
> org.apache.commons.fileupload.MultipartStream$MalformedStreamException: 
> Stream ended unexpectedly
>       at 
> org.apache.commons.fileupload.MultipartStream.readHeaders(MultipartStream.java:540)
>       at 
> org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl.findNextItem(FileUploadBase.java:1038)
>       at 
> org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl.<init>(FileUploadBase.java:1003)
>       at 
> org.apache.commons.fileupload.FileUploadBase.getItemIterator(FileUploadBase.java:310)
>       at 
> org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:334)
>       at 
> org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:115)
>       
> A simple analysis that, when using the browser, file is not selected, the 
> default browser will join the empty data file-part.
> But the use of tools such as httpclient, when the file is empty, it do not 
> contain the documents data.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to