C0urante opened a new pull request, #12666:
URL: https://github.com/apache/kafka/pull/12666

   [Jira](https://issues.apache.org/jira/browse/KAFKA-14244)
   
   Uses an [automatically-registered JUnit 5 
extension](https://junit.org/junit5/docs/snapshot/user-guide/#extensions-registration-automatic)
 that installs a 
[SecurityManager](https://docs.oracle.com/javase/8/docs/api/java/lang/SecurityManager.html)
 which intercepts attempts to terminate the JVM that appear to have come from 
test cases, and then reports those attempts by causing tests to fail. If the 
test that attempted to terminate the JVM is running at the time of the attempt, 
that test will fail. If not, a random test will fail at a later point (in order 
to fail the CI build and surface the issue), with a message reporting that a 
prior test appears to have leaked a thread which has attempted to terminate the 
JVM after that test completed.
   
   The 
[InheritableThreadLocal](https://docs.oracle.com/javase/8/docs/api/java/lang/InheritableThreadLocal.html)
 class is used to track which tests attempt to terminate the JVM, including 
cases where the attempt occurs in a separate thread, and even when the attempt 
has occurred after the test has already completed.
   
   Although the `SecurityManager` API was deprecated and slated for removal in 
[JEP-411](https://openjdk.org/jeps/411), there is no existing alternative for 
intercepting attempts to terminate the JVM (see 
https://bugs.openjdk.org/browse/JDK-8199704). Once an alternative becomes 
available, we can use it instead of the `SecurityManager` API.
   
   This is heavily inspired by the 
[system-rules](https://github.com/stefanbirkner/system-rules) library, with 
some modifications to support parallel testing.
   
   ### Committer Checklist (excluded from commit message)
   - [ ] Verify design and implementation 
   - [ ] Verify test coverage and CI build status
   - [ ] Verify documentation (including upgrade notes)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to