jdk information:
openjdk version "17" 2021-09-14
OpenJDK Runtime Environment Temurin-17+35 (build 17+35)
OpenJDK 64-Bit Server VM Temurin-17+35 (build 17+35, mixed mode, sharing)
spring version:
spring 5.3.9
spring-boot 2.5.3
spring-code: org/springframework/core/io/UrlResource.java at line 269 (return new URL(this.url, relativePath);
)
case: 404 is returned when accessing the local file system mapping URL。
solution:org/springframework/core/io/UrlResource.java at line 269
(return new URL(this.url.getProtocol(), this.url.getHost(), this.url.getPort(), this.url.getPath() + File.separator + relativePath);)
Comment From: jhoeller
Are you seeing a difference in behavior between JDK 8 and 17 there, right there in new URL(this.url, relativePath)
behavior? We are not aware of this yet, it would be great to get some pointers for what specifically has changed (and why this has been changed) in the JDK implementation. Also, in which usage scenarios of UrlResource
is this showing up (e.g. classpath scanning or static web resources)?
Ideally we'd hold on to the URL spec constructor since that algorithm is rather involved, just covering the context path case as needed here. We might see regressions for other scenarios if we're simply replacing this with regular URL
construction.
Comment From: stotem
After checking the source code and testing for many times, no problem was found. I'm very sorry