Refine location checks for PathResource
This commit ensures that checks for PathResource locations are skipped because this resource implementation will always resolve under the current location. Closes gh-34167
This commit is contained in:
@@ -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.
|
||||||
@@ -24,6 +24,7 @@ import org.apache.commons.logging.Log;
|
|||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
|
import org.springframework.core.io.PathResource;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
import org.springframework.core.io.UrlResource;
|
import org.springframework.core.io.UrlResource;
|
||||||
import org.springframework.core.log.LogFormatUtils;
|
import org.springframework.core.log.LogFormatUtils;
|
||||||
@@ -56,7 +57,10 @@ public abstract class ResourceHandlerUtils {
|
|||||||
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 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) {
|
||||||
|
|||||||
@@ -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.
|
||||||
@@ -24,6 +24,7 @@ import org.apache.commons.logging.Log;
|
|||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
|
import org.springframework.core.io.PathResource;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
import org.springframework.core.io.UrlResource;
|
import org.springframework.core.io.UrlResource;
|
||||||
import org.springframework.core.log.LogFormatUtils;
|
import org.springframework.core.log.LogFormatUtils;
|
||||||
@@ -57,7 +58,10 @@ public abstract class ResourceHandlerUtils {
|
|||||||
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 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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user