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

Plugin leaks classloaders when using in-process strategy #168

Closed
marcphilipp opened this issue Apr 2, 2019 · 3 comments
Closed

Plugin leaks classloaders when using in-process strategy #168

marcphilipp opened this issue Apr 2, 2019 · 3 comments
Assignees
Labels
Milestone

Comments

@marcphilipp
Copy link
Contributor

When scanning for bindings in dependencies, the plugin creates a URLClassLoader that is never closed:

https://github.com/highsource/maven-jaxb2-plugin/blob/3c15b7ee35940859ab75e503ea1bbab89400b9fc/plugin-core/src/main/java/org/jvnet/jaxb2/maven2/RawXJC2Mojo.java#L810

As a result, the underlying JARs in that classloader remain open and cannot be deleted. Also, their content can be stale when opened using java.util.ZipFile.

This is a problem when running Maven integration tests using Embedded3xLauncher. We are developing a Maven extension and want to make sure it works well with this plugin. This classloader leak means we have to use a forking launcher instead, which slows down our tests considerably.

@highsource highsource self-assigned this Apr 2, 2019
@highsource highsource added the bug label Apr 2, 2019
@highsource highsource added this to the 0.14.x milestone Apr 2, 2019
@highsource
Copy link
Owner

I wonder how one would safely close the class loader.

@marcphilipp
Copy link
Contributor Author

I may be missing sth. but since the method only returns URIs, I don't see why it would not be safe to close it.

@marcphilipp
Copy link
Contributor Author

@highsource I've submitted a PR to fix this in #169.

highsource added a commit that referenced this issue Apr 14, 2019
laurentschoelens added a commit to laurentschoelens/jaxb-tools that referenced this issue Jul 3, 2023
…n with jaxb-maven-plugin (highsource#169)

Co-authored-by: Laurent SCHOELENS <laurent.schoelens@sfr.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants