File tree 1 file changed +7
-1
lines changed
spring-core/src/main/java/org/springframework/core/io/support 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -445,12 +445,18 @@ protected Resource convertClassLoaderURL(URL url) {
445
445
if (!cleanedPath .equals (urlString )) {
446
446
// Prefer cleaned URL, aligned with UrlResource#createRelative(String)
447
447
try {
448
- return new UrlResource (ResourceUtils .toURI (cleanedPath ));
448
+ // Cannot test for URLStreamHandler directly: URL equality for same String
449
+ // in order to find out whether original URL uses default URLStreamHandler.
450
+ if (ResourceUtils .toURL (urlString ).equals (url )) {
451
+ // Plain URL with default URLStreamHandler -> replace with cleaned path.
452
+ return new UrlResource (ResourceUtils .toURI (cleanedPath ));
453
+ }
449
454
}
450
455
catch (URISyntaxException | MalformedURLException ex ) {
451
456
// Fallback to regular URL construction below...
452
457
}
453
458
}
459
+ // Retain original URL instance, potentially including custom URLStreamHandler.
454
460
return new UrlResource (url );
455
461
}
456
462
}
You can’t perform that action at this time.
0 commit comments