UndertowServletWebServerFactory does not configure a temporary directory #17778
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.