Skip to content

Fix QuarkusClassLoaderHandler on Quarkus 2.7.#642

Merged
lukehutch merged 1 commit into
classgraph:latestfrom
michael-simons:issues/641
Feb 11, 2022
Merged

Fix QuarkusClassLoaderHandler on Quarkus 2.7.#642
lukehutch merged 1 commit into
classgraph:latestfrom
michael-simons:issues/641

Conversation

@michael-simons

Copy link
Copy Markdown
Contributor

In Quarkus 2.7, the class loader stopped returning JarClassPathElement
or DirectoryClassPathElement entries. Instead, some implementation of
ClassPathElement is returned. This change tries to access it's
getRoot method, returning a java.nio.file.Path pointing to the root
of the element, as supported with class graph.

The behaviour has been verified on Quarkus 2.6 and Quarkus 2.7.

This is a fix for #641, thanks @lukehutch in advance for considering this input. It would help Neo4j a lot.

In Quarkus 2.7, the class loader stopped returning `JarClassPathElement`
or `DirectoryClassPathElement` entries. Instead, some implementation of
`ClassPathElement` is returned. This change tries to access it's
`getRoot` method, returning a `java.nio.file.Path` pointing to the root
of the element, as supported with class graph.

The behaviour has been verified on Quarkus 2.6 and Quarkus 2.7.
@michael-simons

Copy link
Copy Markdown
Contributor Author

Do you need anything more / help from me?

} else {
Object rootPath = ReflectionUtils.invokeMethod(false, element, "getRoot");
if (rootPath instanceof Path) {
classpathOrder.addClasspathEntry(ReflectionUtils.invokeMethod(false, element, "getRoot"),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll merge this, but why did you invoke this method twice? Why not just use the value of rootPath?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooops. That was an oversight. You fixed this, didn't you? Thank you for that!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did, no problem!

@lukehutch

Copy link
Copy Markdown
Member

Do you need anything more / help from me?

No, sorry, I have just been traveling for the last 3 weeks, with very limited time... Merging this now -- thank you for the contribution!

@lukehutch lukehutch merged commit 7ac066c into classgraph:latest Feb 11, 2022
lukehutch added a commit that referenced this pull request Feb 11, 2022
@lukehutch

Copy link
Copy Markdown
Member

@michael-simons I had a bunch of other bugfixes I wanted to get in before the next release, but since I'm finding very little time while traveling, and since this seems like an urgent bug for your team, I will push a release out now. Should be fixed in 4.8.139. Thanks for the patch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants