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

Fix QuarkusClassLoaderHandler on Quarkus 2.7. #642

Merged
merged 1 commit into from
Feb 11, 2022

Conversation

michael-simons
Copy link
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
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
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
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
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
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
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.

None yet

2 participants