-
Notifications
You must be signed in to change notification settings - Fork 5
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
Using terminally deprecated method System::setSecurityManager #10
Comments
Hi @relnah, thanks for letting me know about this, and for your kind words! People might get this warning when using junit5-system-exit on Java 17 or higher because Java's Security Manager has been deprecated for removal in JEP-411. Under the covers, this extension uses the Security Manager in order to detect when the JVM is attempting to exit, and prevent it from doing so. I wrote a blog post on how this extension works, if you are interested in the details. Unfortunately, the deprecation warning does not come with instructions on what we're supposed to do instead. Indeed, JEP-411 mentions that this is a use case they need to consider covering:
So for now, there's nothing we can do except wait. I know this extension isn't the only library using the Java Security Manager to do this kind of work. I'm sorry your logs will be polluted with the warning until there's a new way to detect and prevent I'm going to leave this issue open in case other people come here looking for a solution. I've been following JEP-411 as closely as I can, and I will attempt to upgrade this plugin (or provide another) to whatever mechanism comes out that meets our needs. |
The default behaviour changed in Java 18b21 to throw an UnsupportedOperationException when calling the security manager if This is the result when running a test with Java 18:
|
Thanks @don-vip I appreciate the example and links. I'll try to add something to the README about this. I wish there was an approved way to do this, but I'm still waiting for that. |
Update: Not much to say but I am still following developments in regards to a replacement for SecurityManager::checkExit, which this library uses to perform its core function. The JDK issue for this work has received some comments recently, which hopefully will get some attention or clarification soon. |
Just an update that I'm still keeping my eye on a solution for this. The JDK issue raised for it has not seen any movement in nearly a year, but I'll keep checking. |
For anyone still hitting this issue while migrating to Java 21. I had code that was using checkExit to ensure a failing service was being stopped with required value returned. This testing was being done through junit test run by gradle. I found that adding the following allowed me to get past the deprecation issue. I believe that null for this value won't allow a security manager to be created (the one to do the exit mocking) and an exception is thrown but setting to allow will allow the mock to be created.
I didn't have this issue with java 17, well it might have issued a deprecation warning but didn't throw an exception. I did look at other libraries but was getting the same issue - presumably as they all go through this system file and hit the same code. |
Thanks for the note @hardboiledphil, I've updated the README to account for this. Still no word on what the future is like for preventing |
I have just released v2.0.0, which should address issues with the terminally deprecated |
Hi!
Running your excellent extension with Java 17 and this caught my eye.
The text was updated successfully, but these errors were encountered: