damccorm opened a new pull request, #39658:
URL: https://github.com/apache/beam/pull/39658

   ## Description
   
   In Java 20+, `Thread.stop()` unconditionally throws 
`java.lang.UnsupportedOperationException` (JEP 421).
   Following the CI upgrade to Java 21 in #39205, the 
`beam_PostRelease_NightlySnapshot` validation workflow began timing out at 6 
hours because `mobilegaming-java-direct.groovy` and 
`mobilegaming-java-dataflow.groovy` relied on `Thread.stop()` to stop 
background injector and leaderboard threads.
   
   When `Thread.stop()` threw `UnsupportedOperationException`, the main test 
thread crashed and left the background `Injector` process running indefinitely 
as an orphan, publishing messages to Pub/Sub and hanging the build until the 
6-hour execution timeout was hit.
   
   This change:
   1. Adds `runBackground`, `stopProcess`, and `stopAllBackgroundProcesses` to 
`TestScripts.groovy` to manage and cleanly terminate child background processes 
(and their process trees) using Java's `ProcessHandle` APIs.
   2. Registers a JVM shutdown hook in `TestScripts` to guarantee all spawned 
background processes are forcibly destroyed when the script finishes or exits.
   3. Updates `mobilegaming-java-direct.groovy` and 
`mobilegaming-java-dataflow.groovy` to use `t.runBackground` and 
`t.stopProcess`.
   
   ------------------------
   
   Thank you for your contribution! Follow this checklist to help us 
incorporate your contribution quickly and easily:
   
    - [x] Mention the appropriate issue in your description (for example: 
`addresses #123`), if applicable. This will automatically add a link to the 
pull request in the issue. If you would like the issue to automatically close 
on merging the pull request, comment `fixes #<ISSUE NUMBER>` instead.
    - [ ] Update `CHANGES.md` with noteworthy changes.
    - [x] If this contribution is large, please file an Apache [Individual 
Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   See the [Contributor Guide](https://beam.apache.org/contribute) for more 
tips on [how to make review process 
smoother](https://github.com/apache/beam/blob/master/CONTRIBUTING.md#make-the-reviewers-job-easier).


-- 
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