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 a7104a8c135..bd5ab771df2 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,11 +52,15 @@ public abstract class ResourceHandlerUtils { /** * Assert the given location is not null, and its path ends on slash. */ + @SuppressWarnings("removal") public static void assertResourceLocation(@Nullable Resource location) { Assert.notNull(location, "Resource location must not be null"); try { String path; - if (location instanceof UrlResource) { + if (location instanceof org.springframework.core.io.PathResource) { + return; + } + else if (location instanceof UrlResource) { path = location.getURL().toExternalForm(); } else if (location instanceof ClassPathResource classPathResource) { 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 f4d80c2b0e1..f3119f5d355 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,11 +53,15 @@ public abstract class ResourceHandlerUtils { /** * Assert the given location is not null, and its path ends on slash. */ + @SuppressWarnings("removal") public static void assertResourceLocation(@Nullable Resource location) { Assert.notNull(location, "Resource location must not be null"); try { String path; - if (location instanceof UrlResource) { + if (location instanceof org.springframework.core.io.PathResource) { + return; + } + else if (location instanceof UrlResource) { path = location.getURL().toExternalForm(); } else if (location instanceof ClassPathResource classPathResource) {