From 628261d5bb3a8559f1c05ca2e613cdf0f0858517 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Tue, 5 May 2026 11:11:13 +0200 Subject: [PATCH] Do not warn against Root Servlet context location Closes gh-36692 --- .../web/reactive/resource/ResourceHandlerUtils.java | 4 ---- .../web/servlet/resource/ResourceHandlerUtils.java | 4 ---- 2 files changed, 8 deletions(-) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/resource/ResourceHandlerUtils.java b/spring-webflux/src/main/java/org/springframework/web/reactive/resource/ResourceHandlerUtils.java index 2e95c58fd5b..15d3cac542d 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/resource/ResourceHandlerUtils.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/resource/ResourceHandlerUtils.java @@ -76,10 +76,6 @@ public abstract class ResourceHandlerUtils { } else if (location instanceof ContextResource contextResource) { path = contextResource.getPathWithinContext(); - if ("/".equals(path)) { - logger.warn("Resource location '" + location + "' is considered unsafe " + - "and should not be used as it provides access to the root servlet context."); - } } else if (location instanceof UrlResource) { path = location.getURL().toExternalForm(); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHandlerUtils.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHandlerUtils.java index 5b1a133c8fa..884181b6b67 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHandlerUtils.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHandlerUtils.java @@ -77,10 +77,6 @@ public abstract class ResourceHandlerUtils { } else if (location instanceof ContextResource contextResource) { path = contextResource.getPathWithinContext(); - if ("/".equals(path)) { - logger.warn("Resource location '" + location + "' is considered unsafe " + - "and should not be used as it provides access to the root servlet context."); - } } else if (location instanceof UrlResource) { path = location.getURL().toExternalForm();