Skip to content

LocalChannel: Remove dependency on SingleThreadEventExecutor#16393

Merged
chrisvest merged 1 commit into
4.2from
local_shutdown_hook_removal
Mar 3, 2026
Merged

LocalChannel: Remove dependency on SingleThreadEventExecutor#16393
chrisvest merged 1 commit into
4.2from
local_shutdown_hook_removal

Conversation

@normanmaurer
Copy link
Copy Markdown
Member

Motivation:

LocalChannel had a hard dependency on SingleThreadEventExecutor which is not needed if an IoEventLoop is used.

Modifications:

Remove hard dependency

Result:

LocalChannels can be used with all IoEventLoop implementations

Motivation:

LocalChannel had a hard dependency on SingleThreadEventExecutor which is not needed if an IoEventLoop is used.

Modifications:

Remove hard dependency

Result:

LocalChannels can be used with all IoEventLoop implementations
@normanmaurer normanmaurer modified the milestone: 4.2.11.Final Mar 2, 2026
@normanmaurer normanmaurer added needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. labels Mar 2, 2026
}
((SingleThreadEventExecutor) eventLoop()).addShutdownHook(shutdownHook);
EventLoop loop = eventLoop();
if (!(loop instanceof IoEventLoop) && loop instanceof SingleThreadEventExecutor) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IoEventLoop will close the channel already once shutdown so the hook is not needed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just

     if (loop instanceof SingleThreadEventExecutor) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because our IoEventLoop implementations are sub-types of it and don't need it

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then seems we can just override the addshutdownhook with a noop

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No ... people still might want to add hooks . It's just not needed for this channel itself

protected boolean isCompatible(EventLoop loop) {
return loop instanceof SingleThreadEventLoop ||
(loop instanceof IoEventLoopGroup && ((IoEventLoopGroup) loop).isCompatible(LocalServerUnsafe.class));
(loop instanceof IoEventLoop && ((IoEventLoop) loop).isCompatible(LocalServerUnsafe.class));
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IoEventLoop is more correct here.

@chrisvest chrisvest merged commit d9293d2 into 4.2 Mar 3, 2026
26 checks passed
@chrisvest chrisvest deleted the local_shutdown_hook_removal branch March 3, 2026 01:40
@netty-project-bot
Copy link
Copy Markdown
Contributor

Could not create auto-port PR.
Got conflicts when cherry-picking onto 5.0.

normanmaurer added a commit that referenced this pull request Mar 3, 2026
Motivation:

LocalChannel had a hard dependency on SingleThreadEventExecutor which is
not needed if an IoEventLoop is used.

Modifications:

Remove hard dependency

Result:

LocalChannels can be used with all IoEventLoop implementations
chrisvest pushed a commit that referenced this pull request Mar 3, 2026
…#16405)

Motivation:

LocalChannel had a hard dependency on SingleThreadEventExecutor which is
not needed if an IoEventLoop is used.

Modifications:

Remove hard dependency

Result:

LocalChannels can be used with all IoEventLoop implementations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants