konlue opened a new pull request, #7782:
URL: https://github.com/apache/shenyu/pull/7782
Fixes #7774.
## Summary
`ShenyuClusterService` owns the election scheduler but its `shutdown()` —
wired as the bean destroy method in `ClusterConfiguration` — is empty, so
election/renewal activity keeps running against dependencies being destroyed
after the shutdown contract returns.
## Modifications
- Implement `shutdown()`: `shutdownNow()` on the owned scheduler followed by
a bounded `awaitTermination` (5s; warn and continue on timeout so bean
destruction never hangs). Idempotent, and a no-op when the task never started.
- The interrupt surfaces inside the renewal loop, which releases leadership
through its existing `finally releaseMaster()` and closes the upstream/instance
check services via its existing error path — no locks are unlocked from another
thread.
## Verifying this change
- [x] New `ShenyuClusterServiceTest` (first test for the cluster module):
after `shutdown()`, `isShutdown()` is true and no further election attempts
occur; shutdown before start does not throw; shutdown during an active renewal
loop releases leadership (`releaseMaster`) and closes both check services. All
fail on the previous empty `shutdown()` and pass with the fix.
- [x] Targeted tests pass:
```bash
./mvnw -B -ntp -pl shenyu-admin test -Dtest=ShenyuClusterServiceTest
```
3/3 green.
- [x] Checkstyle passes:
```bash
./mvnw -B -ntp -pl shenyu-admin checkstyle:check
```
clean.
## Notes
If the renewal thread is inside a non-interruptible call when shutdown
arrives, the bounded wait logs and returns rather than blocking context
destruction. The interrupt is recorded by the existing `select master error`
log line — expected shutdown noise. Leadership is never released from a foreign
thread.
--
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]