Skip to content
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

RunnerClassLoader getResources returns duplicate results #16770

Closed
Postremus opened this issue Apr 23, 2021 · 4 comments · Fixed by #16782
Closed

RunnerClassLoader getResources returns duplicate results #16770

Postremus opened this issue Apr 23, 2021 · 4 comments · Fixed by #16782
Labels
env/windows Impacts Windows machines kind/bug Something isn't working
Milestone

Comments

@Postremus
Copy link
Member

Postremus commented Apr 23, 2021

Describe the bug

I was updating from 1.12.2 to 1.13.2, and noticed that drools is not initializing anymore.

The root cause seems to be this getResources call, which returns the same file paths multiple times:
https://github.com/kiegroup/droolsjbpm-knowledge/blob/master/kie-api/src/main/java/org/kie/api/internal/utils/ServiceDiscoveryImpl.java#L190

When searching for files, the same file path is listed multiple times.

Enumeration<URL> resources = this.getClass().getClassLoader().getResources("META-INF/kie.conf");

This returns 8 results on 1.13.2, but returned only 4 results on 1.12.2.
For example, the first 2 results are:

jar:file:/C:/workspaces/aviator/drools-113/target/quarkus-app/lib/main/org.kie.kie-internal-7.51.0.Final.jar!/META-INF/kie.conf
jar:file:/C:/workspaces/aviator/drools-113/target/quarkus-app/lib/main/org.kie.kie-internal-7.51.0.Final.jar!/META-INF/kie.conf

Which indicates that a duplication is happening somewhere inside the RunnerClassLoader.

This bug only occurs when running as fast-jar. When starting in dev mode or as legacy-jar, only the expected 4 paths are returned.

Expected behavior

getResources should not return duplicate results.

To Reproduce

Steps to reproduce the behavior:

  1. Download the reproducer: drools-113.zip
  2. mvn clean install
  3. cd target/quarkus-app
  4. java -jar quarkus-run.jar
  5. Visit http://localhost:8080/hello-resteasy. The same files are listed twice.

Environment (please complete the following information):

Output of uname -a or ver

MSYS_NT-10.0 NANB7NLNVP2 2.10.0(0.325/5/3) 2018-06-13 23:34 x86_64 Msys

Output of java -version

GraalVM version (if different from Java)

Quarkus version or git rev:

1.13.0.CR1, 1.13.0.Final, 1.13.1.Final, 1.13.2.Final, 2.0.0.Alpha1

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: C:\eclipse\tools\apache-maven\bin..
Java version: 11.0.7, vendor: Azul Systems, Inc., runtime: C:\eclipse\tools\zulu11.39.15-ca-jdk11.0.7-win_x64
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

@Postremus Postremus added the kind/bug Something isn't working label Apr 23, 2021
@quarkus-bot quarkus-bot bot added the env/windows Impacts Windows machines label Apr 23, 2021
@famod
Copy link
Member

famod commented Apr 23, 2021

/cc @stuartwdouglas @geoand

@geoand
Copy link
Contributor

geoand commented Apr 23, 2021

Interesting, I'll take a look next week

@Postremus
Copy link
Member Author

I tested a bit further, and I think this getResources duplication is caused every time a directory has a non empty sub directory.

This observation also holds true for the drools artifacts. META-INF contains the non empty maven/org.drools/drools-core/ directory, causing the duplication for META-INF/kie.conf.

The following file layout forces the same file path to be returned three times.
image

this.getClass().getClassLoader().getResources("FIRST/FIRST.FILE")

->
[jar:file:/home/martin/IdeaProjects/drools-113/target/quarkus-app/app/drools-113-1.0.0-SNAPSHOT.jar!/FIRST/FIRST.FILE, 
jar:file:/home/martin/IdeaProjects/drools-113/target/quarkus-app/app/drools-113-1.0.0-SNAPSHOT.jar!/FIRST/FIRST.FILE, 
jar:file:/home/martin/IdeaProjects/drools-113/target/quarkus-app/app/drools-113-1.0.0-SNAPSHOT.jar!/FIRST/FIRST.FILE]

https://github.com/quarkusio/quarkus/blob/main/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/runner/SerializedApplication.java#L130

@geoand
Copy link
Contributor

geoand commented Apr 24, 2021

#16782 should take care of it

gastaldi added a commit that referenced this issue Apr 25, 2021
Ensure that RunnerClassLoader returns unique entries
@quarkus-bot quarkus-bot bot added this to the 2.0 - main milestone Apr 25, 2021
@gsmet gsmet modified the milestones: 2.0 - main, 1.13.3.Final Apr 26, 2021
gsmet pushed a commit to gsmet/quarkus that referenced this issue Apr 26, 2021
gsmet pushed a commit to gsmet/quarkus that referenced this issue Apr 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
env/windows Impacts Windows machines kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants