jonathan-albrecht-ibm commented on PR #5231:
URL: https://github.com/apache/hbase/pull/5231#issuecomment-1544312161

   > Mind explain a bit more? IIRC, the SystemExitRule is to forbid System.exit 
call, so what is actual problem here?
   
   Yes, the SystemExitRule is supposed to forbid the System.exit call while a 
test is running so that the various test servers running in the surefire forked 
jvm don't cause it to exit before a test has finished IIUC. The SystemExitRule 
will restore the normal System.exit behaviour when the test completes. The 
problem is, if a test times out, the test doesn't actually complete. The forked 
jvm really does need to exit but the SystemExitRule hasn't restored System.exit 
so it can't.
   
   Note that the timeout exception originates in the timeout rule part of 
HBaseClassTestRule. The timeout rule actually runs the test method in a 
separate thread in a Future with a timeout value.
   
   The change in this PR applies the systemExitRule first so when the timeout 
rule throws an exception it will go through the try...finally block in the 
systemExitRule which restores the normal System.exit and the forked jvm can 
exit normally when it needs to.
   
   Without this change, you can see that 
org.apache.hadoop.hbase.TestSecurityManager shows up in the stacktrace if a 
test times out:
   ```
   Created at 2023-04-27T15:51:58.947
   org.apache.hadoop.hbase.SystemExitRule$SystemExitInTestException
           at 
org.apache.hadoop.hbase.TestSecurityManager.checkExit(TestSecurityManager.java:32)
           at java.base/java.lang.Runtime.exit(Runtime.java:114)
           at java.base/java.lang.System.exit(System.java:1752)
           at 
org.apache.maven.surefire.booter.ForkedBooter.acknowledgedExit(ForkedBooter.java:381)
           at 
org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:178)
           at 
org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:507)
           at 
org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:495)
   ```
   


-- 
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: issues-unsubscr...@hbase.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to