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

[#391] Cope with Thread::stop being unavailable in JDK 20+ #393

Merged
merged 2 commits into from
Nov 11, 2023

Conversation

kriegaex
Copy link
Contributor

In JDK 20+, the long deprecated Thread.stop() (since JDK 1.2) has been removed and will throw an UnsupportedOperationException. This will be handled gracefully when using option stopUnresponsiveDaemonThreads, yielding a log warning "Thread.stop() is unavailable in this JRE version, cannot force-stop any threads" once and not trying to stop any further threads during the same execution.

Tests and documentation have been adjusted accordingly.

Closes #391.

In JDK 20+, the long deprecated Thread.stop() (since JDK 1.2) has been
removed and will throw an UnsupportedOperationException. This will be
handled gracefully when using option 'stopUnresponsiveDaemonThreads',
yielding a log warning "Thread.stop() is unavailable in this JRE
version, cannot force-stop any threads" once and not trying to stop any
further threads during the same execution.

Tests and documentation have been adjusted accordingly.

Closes mojohaus#391.
Because mojohaus#391 introduces special handling of the fact that in JDK 20+
there is no more Thread::stop, we should also run the tests on JDK 21.
@kriegaex
Copy link
Contributor Author

@slawekjaranowski, this is ready for review.

@slawekjaranowski
Copy link
Member

Thanks.

I think we also should deprecate options stopUnresponsiveDaemonThreads of exec:java

@slawekjaranowski slawekjaranowski merged commit 6fae009 into mojohaus:master Nov 11, 2023
28 checks passed
@kriegaex
Copy link
Contributor Author

I think we also should deprecate options stopUnresponsiveDaemonThreads of exec:java

Despite Thread::stop being deprecated for a long time, it still works in JDK 17 LTS, which is just 2 years old, up to JDK 19 (1 year old). Given the fact that the plugin still is built with target 8, JDK 8 LTS being 9 years old, I guess that there might still be Java 17 users for many years to come. I just fixed the build for JDK 21 today. So, of course you can deprecate the option, but probably it will stick around for quite a while.

@kriegaex kriegaex deleted the gh-391 branch November 11, 2023 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Properly handle UnsupportedOperationException thrown by Thread::stop in JDK 20+
2 participants