PathMatchingResourcePatternResolver finds duplicate resources for executable jars but not for executable wars [SPR-14936] #19503
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
Andy Wilkinson opened SPR-14936 and commented
PathMatchingResourcePatternResolver behaves differently depending on the file extension of a Spring Boot executable archive that's been launched with
java -jar
. If the archive is a.jar
file duplicate resources will be found, whereas if the archive is a.war
file they will not. This is due to the logic inaddAllClassLoaderJarRoots
that provides special treatment for.jar
files.I'll attach an application that reproduces the problem.
If you package and run it
You should see the following output:
Note that there are two URLs for
a.zzz
andb.zzz
, one found via the nestedBOOT-INF/classes
"archive" and the other found via the jar root. We only want the entries found via the nested archive.If you run it as a
.war
file:The duplicates are gone and we get the desired result:
I'd like the behaviour to be consistent, irrespective of the file extension that's used for the archive passed to
java -jar
.One final data point. If the archive is unpacked:
And then run:
The duplicates do not occur:
I suspect this is because the URLs are identical, i.e. they do not have the subtle
/
vs!/
difference. This may give us an avenue to explore for fixing the problem in Spring Boot, but I'd like this to be investigated on the Framework side too as the file extension-specific behaviour is rather surprising.Affects: 4.3.4
Attachments:
Issue Links:
Referenced from: commits f16d453, b3e94dc
The text was updated successfully, but these errors were encountered: