fix: prevent Netty command center from blocking JVM shutdown - #3642
Open
lymerin wants to merge 2 commits into
Open
fix: prevent Netty command center from blocking JVM shutdown#3642lymerin wants to merge 2 commits into
lymerin wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe what this PR does / why we need it
The Netty HTTP command center creates boss and worker event-loop threads with Netty's default non-daemon thread factory. Since the global command center is not always tied to an application lifecycle callback, these threads can keep the JVM alive after a Spring ApplicationContext is closed.
In addition, explicit shutdown previously closed the server channel asynchronously and immediately interrupted the executor via shutdownNow(). If the interruption occurred before the channel close completed, closeFuture().sync() threw InterruptedException, and a normal shutdown was incorrectly reported as a server startup failure. A stop request racing with a successful bind could also encounter a null channel or be lost.
This PR prevents the Netty command center from blocking JVM shutdown and avoids exception noise during normal explicit shutdown.
Does this pull request fix one issue?
Fixes #2964
Describe how you did it
Describe how to verify it
Run the Netty HTTP transport module tests with JDK 17:
mvn --batch-mode -pl sentinel-transport/sentinel-transport-netty-http -am testThe regression tests verify that:
All 14 tests in the module pass.
Special notes for reviews
This change is limited to sentinel-transport-netty-http and does not add a Spring dependency or lifecycle hook.
The existing port-binding retry policy is unchanged. stop() remains non-blocking and is not intended to be a synchronous resource-termination barrier.