Skip to content

Commit b7446de

Browse files
committed
Set useCaches on single resources obtained directly from the resource loader before returning it from the PathMatchingResourcePatternResolver
Signed-off-by: Richard Eckart de Castilho <[email protected]>
1 parent 7a5d3a5 commit b7446de

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,13 @@ public Resource[] getResources(String locationPattern) throws IOException {
392392
}
393393
else {
394394
// a single resource with the given name
395-
return new Resource[] {getResourceLoader().getResource(locationPattern)};
395+
Resource res = getResourceLoader().getResource(locationPattern);
396+
if (this.useCaches != null) {
397+
if (resource instanceof UrlResource urlResource) {
398+
urlResource.setUseCaches(this.useCaches);
399+
}
400+
}
401+
return new Resource[] {res};
396402
}
397403
}
398404
}

0 commit comments

Comments
 (0)