konlue opened a new pull request, #7699:
URL: https://github.com/apache/shenyu/pull/7699
Fixes #7686.
## Modifications
`AbstractLogConsumeClient.close()` removed its own shutdown hook before any
exception handling. When `close()` runs from the hook thread during JVM
shutdown, `Runtime.removeShutdownHook` throws `IllegalStateException: Shutdown
in progress`, so `close0()` was never reached on the shutdown path and the
backend was not flushed or cleaned up.
Hook removal now tolerates `IllegalStateException`: during shutdown the
removal is both impossible and unnecessary, and cleanup proceeds to `close0()`.
The single call into `Runtime` is isolated in a protected `removeHook` method
so the shutdown-time failure can be reproduced deterministically instead of
depending on real JVM shutdown. `isStarted` is flipped with
`compareAndSet(true, false)`, so `close0()` runs exactly once across explicit
close, re-initialization and the shutdown hook; previously a concurrent close
could run cleanup twice.
## Verifying this change
- [x] New `testClose0StillRunsWhenHookRemovalFails`: throws
`IllegalStateException("Shutdown in progress")` from the hook-removal seam and
asserts `close0()` still executes. Errors on the pre-fix code, green after.
- [x] New `testCloseIsIdempotent`: repeated close runs `close0()` exactly
once.
- [x] Targeted tests pass:
```bash
./mvnw -B -ntp -pl
shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common -am test
-Dmaven.javadoc.skip=true
```
62/62 green.
## Notes
- The ElasticSearch, Kafka and RocketMQ log clients extend the base class
but do not override `close()`, so no downstream change is needed.
--
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]