Creating relative resource for URL resource should create relative Resource even if relative path has URL in it #28522
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
in: web
Issues in web modules (web, webmvc, webflux, websocket)
type: enhancement
A general enhancement
Milestone
Affects: 5.3.19 (most likely any version)
We were using the combination of
ResourcePatternResolver#getResources
andResource#createRelative
for something and received a bug report from a client that doingResource#createRelative
was resolving to an entirely different resource.e.g.
We have an empty folder named
reports
on the classpath and if we run the test below it is going to fail because the creation of a relative resource for "http://localhost:8080" will be a resource pointing to that URL and not relative to "classpath*:reports/"We realized that in this example the resolved resource for "classpath*:reports/" is a
UrlResource
and doingcreateRelative
on it will delegate to the JDKnew URL(this.url, relativePath)
.We were expecting that doing
Resource#createRelative
will treat the passed relative path as relative, irregardless whether it is a URL, or something else. Were we wrong with our expectations?The text was updated successfully, but these errors were encountered: