From c6b485c31d4fc8c2d258665b46a6eafca020ac8b 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-36693 --- .../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 3c33d7d7915..4eefb43debd 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 @@ -75,10 +75,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 f576776e93c..73c01cb48aa 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 @@ -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();