You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by "Aias00 (via GitHub)" <gi...@apache.org> on 2026/08/03 01:13:18 UTC

[I] [BUG] TakeoverOtherHooksThread throws uncaught NPE when ApplicationShutdownHooks reflection fails [shenyu]

Aias00 opened a new issue, #6786:
URL: https://github.com/apache/shenyu/issues/6786

   - Severity: Medium
   - Location:
   `shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/shutdown/ShenyuClientShutdownHook.java:85-96`
   - 
   Description:
   In `TakeoverOtherHooksThread.run()`, the reflection block (lines 86-93) attempts to get `java.lang.ApplicationShutdownHooks.hooks`. If this fails (`ClassNotFoundException`, `NoSuchFieldException`, `IllegalAccessException` — restricted SecurityManager, non-standard/future JDK where the internal class changes), `hooks` remains null. The catch logs the error but execution continues to line 95's while loop. At line 96, `Objects.requireNonNull(hooks)` throws `NullPointerException` outside any try-catch; the thread terminates with an uncaught exception. The entire "delay other shutdown hooks" mechanism (which ensures the shenyu offline event reaches admin before Spring's shutdown hooks close connections) is silently broken.
   - 
   Impact:
   On environments where `ApplicationShutdownHooks` reflection fails, shutdown-hook delay is inactive. The client's `closeRepository`/`offline` may race with or run after Spring's connection-closing hooks, so the offline event never reaches admin. Stale URI entries persist on the admin side.
   - 
   Suggested fix:
   Add `if (hooks == null) { LOG.warn("Could not access ApplicationShutdownHooks, skipping hook delay"); return; }` immediately after the try-catch block (before line 94).
   - 
   Confidence: High
   - Related existing: none
   
   ---
   _Identified during the 2026-08-02 deep re-scan; full list in [`docs/scan2-2026-08-02/06-medium-tiers.md`](docs/scan2-2026-08-02/06-medium-tiers.md)._


-- 
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: notifications-unsubscribe@shenyu.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [BUG] TakeoverOtherHooksThread throws uncaught NPE when ApplicationShutdownHooks reflection fails [shenyu]

Posted by "Aias00 (via GitHub)" <gi...@apache.org>.
Aias00 closed issue #6786: [BUG] TakeoverOtherHooksThread throws uncaught NPE when ApplicationShutdownHooks reflection fails
URL: https://github.com/apache/shenyu/issues/6786


-- 
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: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [BUG] TakeoverOtherHooksThread throws uncaught NPE when ApplicationShutdownHooks reflection fails [shenyu]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #6786:
URL: https://github.com/apache/shenyu/issues/6786#issuecomment-5161319250

   👋 Hello @Aias00
   
   A new issue has been opened by @Aias00:
   - **Title**: [BUG] TakeoverOtherHooksThread throws uncaught NPE when ApplicationShutdownHooks reflection fails
   - **Link**: https://github.com/apache/shenyu/issues/6786
   
   Please review when you have time. Thank you! 🙏


-- 
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: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org