-
Notifications
You must be signed in to change notification settings - Fork 40.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UndertowServletWebServerFactory does not configure a temporary directory #17778
Conversation
@Roiocam Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@Roiocam Thank you for signing the Contributor License Agreement! |
@Roiocam Would it be possible to add a test case for this? |
@mbhave it's complicated to make a JUint case for this bug. But i make a minimal application to reproduce this. See more detail In header block comment at the top of NpeDemoApplication.java |
@Roiocam thank you for making your first contribution to Spring Boot. They are indeed a couple of cases where Undertow expects the temporary directory to be set as a fallback option, the lack of a valid multipart location being one of them. Turns out we have an infrastructure to create a temporary directory for the container so I've polished your contribution and used that. I've also added a test (agree it wasn't easy to setup so something we should probably improve). |
It's great to see that my opinion was helpfully, I've seen how good it isthe change from you about the commit. It's seem that i should be more familiar with the project. |
Description
I am using Spring Boot undertow construct upload file class, the configuration of the
spring.servlet.multipart.location
attributes, when the attribute value and the current environment is not configured at the same time, the undertowManagedServlet setupMultipart
method to obtain theservletContext.getDeployment().getDeploymentInfo().getTempPath()
returns value. But this method doesn't seem to return the correct value. So the program throw the NPE .Steps to Reproduce:
In Windows, I use
spring.servlet.multipart.location=/opt/jar-application-dir
And then
io.undertow.servlet.core.ManagedServlet
Line 75 , will returnfalse
then in line 78 will throw theNullPointException
. The reason is fieldtempDir
wasnull
.In Linux, I use
spring.servlet.multipart.location=C://jar-application-dir
and thenio.undertow.servlet.core.ManagedServlet
Line 75 , will returnfalse
then in line 78 will throw theNullPointException
. The reason is fieldtempDir
wasnull
.Seem like the method
Path.isAbsolute()
can not recognize diffrent OS file system. and thenUndertowServletWebServerFactory.createDeploymentManager()
didn't init the fieldtempDir
This is exception stacktrace :
Fix :
First of all, i think the issue will be 'Undertow' cecause the exception was throw by Undertow Project object. But i trace the running stack,seem like
UndertowServletWebServerFactory
create an object but didn't giving a default value.So i push this commit , hope it's helpful.