Aias00 opened a new issue, #7686: URL: https://github.com/apache/shenyu/issues/7686
### Current behavior `AbstractLogConsumeClient.initClient()` registers `new Thread(this::close)` as a JVM shutdown hook. `close()` first calls `Runtime.removeShutdownHook(...)`, outside its exception handler. Once JVM shutdown has begun, removing a hook throws `IllegalStateException: Shutdown in progress`; execution never reaches `close0()`. ### Location - [Hook registration and close implementation](https://github.com/apache/shenyu/blob/66d7d954ca37d651a5ad916f988a8081157a7ab4/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/client/AbstractLogConsumeClient.java#L78), particularly line 87 before the cleanup at line 92. ### Impact and priority **P2 / Medium.** The fallback JVM-shutdown cleanup path is broken for logging clients using this base class. Backend cleanup and any flushing implemented in `close0()` are skipped. Other framework cleanup may run first in a particular deployment, so the report does not claim every shutdown loses logs. ### Reproduction and evidence Compile the current base class with a minimal subclass whose `initClient0()` returns `true`, and whose `close0()` prints a marker. Call `initClient(new GenericGlobalConfig())`, then `System.exit(0)` in a child JVM. Observed output on Java 17: ```text INITIALIZED EXITING Exception in thread "Thread-0" java.lang.IllegalStateException: Shutdown in progress at java.base/java.lang.ApplicationShutdownHooks.remove(ApplicationShutdownHooks.java:82) at java.base/java.lang.Runtime.removeShutdownHook(Runtime.java:245) at org.apache.shenyu.plugin.logging.common.client.AbstractLogConsumeClient.close(AbstractLogConsumeClient.java:87) ``` The `close0()` marker is never printed. This is an executable reproduction of the current base-class lifecycle, not an assertion about every external logging backend. ### Expected behavior / suggested fix Shutdown-hook removal must not prevent resource cleanup. Handle the JVM-shutdown case separately or tolerate `IllegalStateException` around hook removal, and make cleanup idempotent across explicit close and the hook. ### Related existing work Searched all 3,074 existing issue titles and targeted live searches. #6886 and #6768 concern extra/untracked hooks; #6763 concerns buffered records in the collector. This report is the independent base-client exception that prevents its own hook from reaching cleanup. ### Environment Apache ShenYu `2.7.2-SNAPSHOT`, `master@66d7d954ca37d651a5ad916f988a8081157a7ab4`; Java 17. Unit-test and CI issue categories excluded. -- 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]
