File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
spring-core/src/main/java/org/springframework/core/io/support Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -428,12 +428,18 @@ protected Resource convertClassLoaderURL(URL url) {
428
428
if (!cleanedPath .equals (urlString )) {
429
429
// Prefer cleaned URL, aligned with UrlResource#createRelative(String)
430
430
try {
431
- return new UrlResource (ResourceUtils .toURI (cleanedPath ));
431
+ // Cannot test for URLStreamHandler directly: URL equality for same String
432
+ // in order to find out whether original URL uses default URLStreamHandler.
433
+ if (ResourceUtils .toURL (urlString ).equals (url )) {
434
+ // Plain URL with default URLStreamHandler -> replace with cleaned path.
435
+ return new UrlResource (ResourceUtils .toURI (cleanedPath ));
436
+ }
432
437
}
433
438
catch (URISyntaxException | MalformedURLException ex ) {
434
439
// Fallback to regular URL construction below...
435
440
}
436
441
}
442
+ // Retain original URL instance, potentially including custom URLStreamHandler.
437
443
return new UrlResource (url );
438
444
}
439
445
}
You can’t perform that action at this time.
0 commit comments