FileUpload: throws RuntimeExceptions when chunked mode is used
See original GitHub issueDescribe the defect
- Chunked FileUpload throws RuntimeException if
UPLOADER=native.
java.util.NoSuchElementException
at java.base/java.util.HashMap$HashIterator.nextNode(HashMap.java:1495)
at java.base/java.util.HashMap$KeyIterator.next(HashMap.java:1516)
at java.base/java.util.Collections$3.nextElement(Collections.java:5267)
at org.primefaces.component.fileupload.NativeFileUploadDecoder.lambda$getUploadDirectory$3(NativeFileUploadDecoder.java:79)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.base/java.util.stream.Streams$StreamBuilderImpl.tryAdvance(Streams.java:397)
at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543)
at org.primefaces.component.fileupload.NativeFileUploadDecoder.getUploadDirectory(NativeFileUploadDecoder.java:82)
- Chunked FileUpload throws NPE if
UPLOADER=comonsand<init-param><param-name>uploadDirectory</param-name>...</init-param>is not configured inweb.xml
java.lang.NullPointerException: Cannot invoke "java.io.File.getAbsolutePath()" because the return value of "org.primefaces.webapp.MultipartRequest.getUploadDirectory()" is null
at org.primefaces.component.fileupload.CommonsFileUploadDecoder.getUploadDirectory(CommonsFileUploadDecoder.java:80)
at org.primefaces.component.fileupload.CommonsFileUploadDecoder.getUploadDirectory(CommonsFileUploadDecoder.java:36)
Reproducer Former issue cannot be reproduced with primefaces-test project, since jetty adds some attributes to the request which hide the bug.
Reproducer for latter issue. PF-7617-chunked.zip
Environment:
- PF Version: 10.0
- JSF + version: ALL
- Affected browsers: ALL
To Reproduce Steps to reproduce the behavior:
- Start server
mvn jetty:run - Go to ‘localhost:8080/primefaces-test/’
- Click ‘choose’
- Select any file bigger than 1MB
- Click ‘upload’
- See error in server log
Expected behavior RuntimeExceptions should not be thrown. Files should be uploaded without error.
Example XHTML
<h:form id="frmTest">
<p:fileUpload id="fileupload" mode="advanced" maxChunkSize="65536" .../>
</h:form>
Example Bean see reproducer
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6 (6 by maintainers)
Top Results From Across the Web
IIS7 refuses chunked-encoded file upload - Stack Overflow
I have a Windows/Apache2/PHP app that receives file using chunked encoding. The reason is that the file uploaded is dynamic and its length...
Read more >Solved: Uploading file Via REST API and Triggering Imports
I am following this API Request: Upload a single chunk ... canRead()) { throw new RuntimeException("Input file must be a valid file. File...
Read more >Java Stream - 2.8.x - Play Framework
Let's just use this streamed HttpEntity to specify the response body: ... For this kind of response we have to use Chunked transfer...
Read more >Handling file uploads - Manual - PHP
throw new RuntimeException('Failed to move uploaded file. ... If you are going to do a file upload, I recommend you use the PHP...
Read more >ojluni/src/main/java/java/net/HttpURLConnection.java
To upload data to a web server, configure the connection for output using ... throw new IllegalStateException ("Chunked encoding streaming mode set");.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I assigned it to you. Thanks!
primefaces-integration-test project utilizes TomEE. Looks like TomEE does not add request attributes (in contrary to Jetty). And the Reproducer does not set request attributes at all.