Skip to content

[ISSUE #11080] Skip unused remoting client event executor - #11081

Merged
lizhimins merged 1 commit into
apache:developfrom
qianye1001:codex/skip-unused-netty-event-executor
Sep 10, 2026
Merged

[ISSUE #11080] Skip unused remoting client event executor#11081
lizhimins merged 1 commit into
apache:developfrom
qianye1001:codex/skip-unused-netty-event-executor

Conversation

@qianye1001

Copy link
Copy Markdown
Contributor

Which Issue(s) This PR Fixes

Fixes #11080

Brief Description

NettyRemotingClient.start() starts a NettyEventExecutor even when no ChannelEventListener is configured. Since connection handlers already skip event submission in that case, each such client keeps an unused thread polling an empty queue every three seconds. This includes internal clients built through MQClientAPIExt.

Start the executor only when channelEventListener != null. Clients with a listener retain their existing event dispatch behavior. The existing shutdown implementation safely handles an executor that was never started.

How Did You Test This Change?

Added regression tests covering startup and shutdown without an event thread when no listener is configured, and ACTIVE event delivery plus thread termination when a listener is configured.

Passed on JDK 11:

mvn -B -pl remoting -am -Dtest=NettyRemotingClientTest -Dsurefire.failIfNoSpecifiedTests=false test

All 16 tests passed, including the two new tests. Checkstyle and SpotBugs also passed.

@RockteMQ-AI RockteMQ-AI left a comment

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.

Summary

Clean optimization — skip starting NettyEventExecutor when no ChannelEventListener is configured. The executor thread was polling an empty queue every 3 seconds for nothing, so this saves one thread per client instance that doesn't need channel event callbacks.

Review

  • Correctness ✅ — The guard is safe: channelEventListener is set in the constructor and effectively final. Connection handlers already skip event submission when the listener is null, so the executor was indeed doing nothing.
  • Tests ✅ — Good coverage of both paths (with/without listener). The reflection-based thread state verification is a pragmatic choice for lifecycle testing.
  • Performance ✅ — Eliminates unnecessary thread creation and periodic wake-ups. Minor but meaningful for deployments with many client instances.
  • Compatibility ✅ — No API changes, purely internal optimization.

LGTM.


Automated review by github-manager-bot

@codecov-commenter

codecov-commenter commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 48.89%. Comparing base (4fd0e3b) to head (811c92d).

Additional details and impacted files
@@              Coverage Diff              @@
##             develop   #11081      +/-   ##
=============================================
- Coverage      48.92%   48.89%   -0.04%     
+ Complexity     13846    13837       -9     
=============================================
  Files           1382     1382              
  Lines         101602   101603       +1     
  Branches       13213    13214       +1     
=============================================
- Hits           49709    49678      -31     
- Misses         45866    45882      +16     
- Partials        6027     6043      +16     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@qianye1001
qianye1001 force-pushed the codex/skip-unused-netty-event-executor branch from d1fcab1 to 811c92d Compare September 9, 2026 08:54
@lizhimins
lizhimins merged commit df5b53d into apache:develop Sep 10, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement] Skip NettyEventExecutor startup when the remoting client has no channel listener

4 participants