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 support for JVM shutdown hooks #4474

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

marcphilipp
Copy link
Member

Overview

When the ConsoleLauncher is executed via its main method while
passing arguments via its -cp option, it no longer closes the custom
class loader it creates eagerly after test discovery or execution.
Instead, it relies on the JVM shutdown to free up any resource held by
the class loader which is initiated by calling System.exit directly
afterward.

Fixes #4469.


I hereby agree to the terms of the JUnit Contributor License Agreement.


Definition of Done

When the `ConsoleLauncher` is executed via its `main` method while
passing arguments via its `-cp` option, it no longer closes the custom
class loader it creates eagerly after test discovery or execution.
Instead, it relies on the JVM shutdown to free up any resource held by
the class loader which is initiated by calling `System.exit` directly
afterward.

Fixes #4469.
@marcphilipp marcphilipp self-assigned this Apr 11, 2025
@sormuras
Copy link
Member

Could CustomClassLoaderCloseStrategy.CLOSE_AFTER_CALLING_LAUNCHER be the default? This would keep the amount of changes in existing tests lower. Only the real main path with the terminating System.exit(result) call would use CustomClassLoaderCloseStrategy.KEEP_OPEN.

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.

Shutdown hook fails with ClassNotFoundException in junit-platform-console-standalone
2 participants