Browse Source

Merge branch '6.2.x'

pull/34214/head
Brian Clozel 1 year ago
parent
commit
7a71d7c3a8
  1. 8
      spring-webflux/src/main/java/org/springframework/web/reactive/resource/ResourceHandlerUtils.java
  2. 8
      spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHandlerUtils.java

8
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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. * Assert the given location is not null, and its path ends on slash.
*/ */
@SuppressWarnings("removal")
public static void assertResourceLocation(@Nullable Resource location) { public static void assertResourceLocation(@Nullable Resource location) {
Assert.notNull(location, "Resource location must not be null"); Assert.notNull(location, "Resource location must not be null");
try { try {
String path; String path;
if (location instanceof UrlResource) { if (location instanceof org.springframework.core.io.PathResource) {
return;
}
else if (location instanceof UrlResource) {
path = location.getURL().toExternalForm(); path = location.getURL().toExternalForm();
} }
else if (location instanceof ClassPathResource classPathResource) { else if (location instanceof ClassPathResource classPathResource) {

8
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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. * Assert the given location is not null, and its path ends on slash.
*/ */
@SuppressWarnings("removal")
public static void assertResourceLocation(@Nullable Resource location) { public static void assertResourceLocation(@Nullable Resource location) {
Assert.notNull(location, "Resource location must not be null"); Assert.notNull(location, "Resource location must not be null");
try { try {
String path; String path;
if (location instanceof UrlResource) { if (location instanceof org.springframework.core.io.PathResource) {
return;
}
else if (location instanceof UrlResource) {
path = location.getURL().toExternalForm(); path = location.getURL().toExternalForm();
} }
else if (location instanceof ClassPathResource classPathResource) { else if (location instanceof ClassPathResource classPathResource) {

Loading…
Cancel
Save