PathMatchingResourcePatternResolver finds duplicate resources for executable jars but not for executable wars [SPR-14936] #19503
Comments
Juergen Hoeller commented As far as I see, we're simply not considering However, should we actually search other archives as well, simply to be consistent, even if we don't actually want to find those duplicates? Or should we explicitly ignore Since that part of |
Andy Wilkinson commented
An executable war is a jar file, just one with a different extension. Searching the root of any
I think that's really the crux of the matter here. I've been wrestling with it for a while. If we had a good answer to that, whether or not I'd like to explore the avenue of removing the subtle
Thanks. Somewhat ironically, I don't think we need that behaviour for executable jars built with Spring Boot 1.4. However, it is still needed for a shaded jar and for anyone using Spring Boot 1.3. I'll let you know how I get on with addressing this on the Spring Boot side. |
Juergen Hoeller commented The problem is: Coming out of |
Juergen Hoeller commented Since we have defensive URL building and |
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: