ClassPathResource.createRelative is using wrong ClassPathResource constructor for the returned resource [SPR-16146] #20694
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: backported
An issue that has been backported to maintenance branches
type: bug
A general bug
Milestone
Constantino Cronemberger opened SPR-16146 and commented
new ClassPathResource("/test.html") removes the leading slash, but when the method createRelative is called it does not remove the leading slash in the returned resource as in this example:
System.out.println(((ClassPathResource)new ClassPathResource("").createRelative("/test.html")).getPath());
The fix is very simple.
There are two sets of constructors: the ones for when clazz is not specified and the ones for when it is specified.
The createRelative method should choose the right one to use based on the current value of the clazz attribute.
Affects: 4.3.12, 5.0.1
Issue Links:
Referenced from: commits 573ff2c, d00e4f1
Backported to: 4.3.13
The text was updated successfully, but these errors were encountered: