diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/MultipartAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/MultipartAutoConfigurationTests.java index c0f4cb7cef..690ac7b947 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/MultipartAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/MultipartAutoConfigurationTests.java @@ -148,6 +148,16 @@ public class MultipartAutoConfigurationTests { .isSameAs(this.context.getBean(DispatcherServlet.class).getMultipartResolver()); } + @Test + public void webServerWithNonAbsoluteMultipartLocationUndertowConfiguration() { + this.context = new AnnotationConfigServletWebServerApplicationContext( + WebServerWithNonAbsolutePathUndertow.class, BaseConfiguration.class); + this.context.getBean(MultipartConfigElement.class); + verifyServletWorks(); + assertThat(this.context.getBean(StandardServletMultipartResolver.class)) + .isSameAs(this.context.getBean(DispatcherServlet.class).getMultipartResolver()); + } + @Test public void webServerWithMultipartConfigDisabled() { testWebServerWithCustomMultipartConfigEnabledSetting("false", 0); @@ -365,6 +375,27 @@ public class MultipartAutoConfigurationTests { } + @Configuration + @EnableWebMvc + public static class WebServerWithNonAbsolutePathUndertow { + + @Bean + MultipartConfigElement multipartConfigElement() { + return new MultipartConfigElement("test/not-absolute"); + } + + @Bean + UndertowServletWebServerFactory webServerFactory() { + return new UndertowServletWebServerFactory(); + } + + @Bean + WebController webController() { + return new WebController(); + } + + } + @Configuration public static class WebServerWithCustomMultipartResolver { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java index abfcf41595..3bf1bbabf1 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java @@ -259,7 +259,6 @@ public class UndertowServletWebServerFactory extends AbstractServletWebServerFac deployment.setClassLoader(getServletClassLoader()); deployment.setContextPath(getContextPath()); deployment.setDisplayName(getDisplayName()); - deployment.setTempDir(new File(System.getProperty("java.io.tmpdir"))); deployment.setDeploymentName("spring-boot"); if (isRegisterDefaultServlet()) { deployment.addServlet(Servlets.servlet("default", DefaultServlet.class)); @@ -267,6 +266,7 @@ public class UndertowServletWebServerFactory extends AbstractServletWebServerFac configureErrorPages(deployment); deployment.setServletStackTraces(ServletStackTraces.NONE); deployment.setResourceManager(getDocumentRootResourceManager()); + deployment.setTempDir(createTempDir("undertow")); deployment.setEagerFilterInit(this.eagerInitFilters); configureMimeMappings(deployment); for (UndertowDeploymentInfoCustomizer customizer : this.deploymentInfoCustomizers) {