From 13600295b09538017f8475f2c5d6ff1ce7dc06ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Nicoll?= Date: Mon, 12 Aug 2024 15:19:29 +0200 Subject: [PATCH] Upgrade to Jetty 12.0.12 Closes gh-41770 --- .../spring-boot-dependencies/build.gradle | 2 +- .../embedded/jetty/JettyEmbeddedWebAppContext.java | 5 +++++ .../jetty/JettyServletWebServerFactory.java | 14 +++++++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index abbc5475cd..bdac30158a 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -687,7 +687,7 @@ bom { ] } } - library("Jetty", "12.0.11") { + library("Jetty", "12.0.12") { group("org.eclipse.jetty.ee10") { imports = [ "jetty-ee10-bom" diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyEmbeddedWebAppContext.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyEmbeddedWebAppContext.java index baf8e75866..625e7b822f 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyEmbeddedWebAppContext.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyEmbeddedWebAppContext.java @@ -42,6 +42,11 @@ class JettyEmbeddedWebAppContext extends WebAppContext { getContext().call(handler::deferredInitialize, null); } + @Override + public String getCanonicalNameForTmpDir() { + return super.getCanonicalNameForTmpDir(); + } + private static final class JettyEmbeddedServletHandler extends ServletHandler { @Override diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactory.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactory.java index 194fa32ba2..8b2d78b761 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactory.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactory.java @@ -308,9 +308,17 @@ public class JettyServletWebServerFactory extends AbstractServletWebServerFactor private File getTempDirectory(WebAppContext context) { String temp = System.getProperty("java.io.tmpdir"); - return (temp != null) - ? new File(temp, WebInfConfiguration.getCanonicalNameForWebAppTmpDir(context) + UUID.randomUUID()) - : null; + return (temp != null) ? new File(temp, getTempDirectoryPrefix(context) + UUID.randomUUID()) : null; + } + + @SuppressWarnings("removal") + private String getTempDirectoryPrefix(WebAppContext context) { + try { + return ((JettyEmbeddedWebAppContext) context).getCanonicalNameForTmpDir(); + } + catch (Throwable ex) { + return WebInfConfiguration.getCanonicalNameForWebAppTmpDir(context); + } } private void configureDocumentRoot(WebAppContext handler) {