Skip to content

Fat jar has two candidate URLs for classpath*:**/ patterns, leading to resources duplication #7449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
snicoll opened this issue Nov 22, 2016 · 8 comments
Labels
type: bug A general bug type: regression A regression from a previous release
Milestone

Comments

@snicoll
Copy link
Member

snicoll commented Nov 22, 2016

This is a follow-up of SPR-14934.

Assume we need to collect the resources matching the classpath*:/**/*.xml pattern in a Spring Boot application. As of 1.4, two root urls will be used for the search:

jar:file:/Users/foo/SPR-13685/target/SPR-13685-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes!/
jar:file:/Users/foo/SPR-13685/target/SPR-13685-0.0.1-SNAPSHOT.jar!/

The former is the one used by the LaunchedUrlClassLoader and the latter is used by the system classloader. Because we asked to search "everything", the system classloader finds the resource again, leading to a duplication. Arguably, the system classloader must ignore anything in BOOT-INF since it is managed by the LaunchedUrlClassLoader already.

@snicoll snicoll added type: bug A general bug type: regression A regression from a previous release labels Nov 22, 2016
@snicoll snicoll added this to the 1.4.3 milestone Nov 22, 2016
@snicoll snicoll changed the title Fatjar has two URLs for classpath*:**/ type of URL Fat jar has two candidate URLs for classpath*:**/ patterns, leading to resources duplication Nov 22, 2016
@philwebb
Copy link
Member

@wilkinsona will be interested in this one. I hope we don't need to add filtering back to the system classloader.

@kazuki43zoo
Copy link
Contributor

kazuki43zoo commented Nov 30, 2016

@wilkinsona @snicoll

I tried spring boot 1.4.3 and spring 4.3.5 snapshot version, however this issue and SPR-14934 does not resolved in my repro project.

In my repro project is https://github.com/kazuki43zoo/repro-PathMatchingResourcePatternResolver.

$ ./mvnw -U clean package
$ $ java -jar target/path-demo-0.0.1-SNAPSHOT.jar
...
------resources1---------
jar:file:/Users/xxx/git/repro-PathMatchingResourcePatternResolver/target/path-demo-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes!/my/mappers/BarMapper.xml
jar:file:/Users/xxx/git/repro-PathMatchingResourcePatternResolver/target/path-demo-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes!/my/mappers/FooMapper.xml
jar:file:target/path-demo-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes/my/mappers/BarMapper.xml
jar:file:target/path-demo-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes/my/mappers/FooMapper.xml
...

It has been detected same resource twice from relative path and absolute path.

@snicoll
Copy link
Member Author

snicoll commented Nov 30, 2016

@kazuki43zoo I am not sure the framework fix has been backported yet. @jhoeller any idea here?

@kazuki43zoo
Copy link
Contributor

@snicoll Oh... I will confirm it.

@kazuki43zoo
Copy link
Contributor

@snicoll @wilkinsona , thanks for quick replying !! I will try again after backporting to Spring 4.3.x line.
Thanks.

@kazuki43zoo
Copy link
Contributor

Hi @snicoll @wilkinsona @jhoeller, I've tried latest snapshot version. This issue has been resolved !!

@wilkinsona
Copy link
Member

@kazuki43zoo Thanks for the confirmation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug type: regression A regression from a previous release
Projects
None yet
Development

No branches or pull requests

4 participants