wy471x opened a new pull request, #7518: URL: https://github.com/apache/shenyu/pull/7518
[X] I have read the [Contributor Guide](https://shenyu.apache.org/community/contributor-guide) [X] I have added test cases for my changes [X] I have run `./mvnw clean install -Dmaven.javadoc.skip=true` locally ## Summary Addresses #6668. `HierarchicalWheelTimer` created two non-daemon threads (the wheel `workerThread` and the single `taskExecutor` thread) and backed the task executor with an unbounded `LinkedBlockingQueue`. A timer that is never explicitly shut down therefore kept the JVM alive (thread leak on redeploy), and a burst of expirations could grow the queue without limit and queue behind the single consumer. ### Changes: 1. `HierarchicalWheelTimer` constructor (HierarchicalWheelTimer.java) — create the thread factory with `daemon = true` so both the worker thread and the task-executor thread are daemons and can no longer block JVM shutdown. The existing `shutdown()` interrupt path is unchanged. 2. `HierarchicalWheelTimer` constructor (HierarchicalWheelTimer.java) — back the task executor with `ShenyuThreadPoolExecutor` + `MemorySafeTaskQueue` (256 MB free-memory floor), the in-repo memory-safe pool already used by the logging collectors, instead of an unbounded `LinkedBlockingQueue`. 3. `addTimerTaskEntry` (HierarchicalWheelTimer.java) — guard the `submit` with a `RejectedExecutionException` catch plus warning log, so a rejected expired task (queue out of memory) cannot kill the worker loop. ### Test Cases: - `HierarchicalWheelTimerTest#testTimerThreadsAreDaemon` — a scheduled task runs on a daemon thread and the worker thread is a daemon. - `HierarchicalWheelTimerTest#testTaskExecutorQueueIsMemorySafe` — the task executor's queue is a `MemorySafeTaskQueue` (bounded by available memory). - Existing `testShutdownStopsWorkerAndRejectsNewTasks` still passes, confirming shutdown still stops the worker and rejects new tasks. ## Verification - `./mvnw -pl shenyu-common -am test -Dtest=HierarchicalWheelTimerTest` (JDK 21): 7 tests, 0 failures. - `./mvnw -pl shenyu-common -am test` (JDK 21): 441 tests, 0 failures, 1 skipped; BUILD SUCCESS. - `./mvnw -pl shenyu-common validate` (JDK 21): BUILD SUCCESS (checkstyle). Fixes #6668 -- 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]
