Skip to content

[ISSUE #10620] Fix NPE when recording RPC latency for local proxy requests - #10621

Open
majialoong wants to merge 4 commits into
apache:developfrom
majialoong:ISSUE-10620
Open

majialoong wants to merge 4 commits into
apache:developfrom
majialoong:ISSUE-10620

Conversation

@majialoong

Copy link
Copy Markdown
Contributor

Which Issue(s) This PR Fixes

Brief Description

Initialize processTimer for LocalRemotingCommand to prevent an NPE and ensure RPC latency metrics are recorded correctly.

How Did You Test This Change?

Added unit tests to verify that the timer is initialized and RPC latency can be recorded successfully.

@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.

Review by github-manager-bot

Summary

Fixes NPE in NettyRemotingAbstract.writeResponse when recording RPC latency for local proxy requests by initializing processTimer in LocalRemotingCommand.createRequestCommand().

Findings

  • [Info] LocalRemotingCommand.java:35 — Stopwatch.createStarted() is the correct initialization, matching the pattern used by RemotingCommand after NettyDecoder processing. Clean and minimal fix.
  • [Info] LocalRemotingCommandTest.java — Good test coverage with two focused tests: one verifying timer initialization, another verifying the full latency recording flow through writeResponse. The use of NopLongHistogram override and SimpleChannel stub is appropriate.

Suggestions

  • Consider adding a brief comment in LocalRemotingCommand.createRequestCommand() explaining why the timer is initialized here (i.e., local commands bypass NettyDecoder), to help future maintainers understand the context.

Verdict

✅ Approve — Correct fix for a real NPE bug. The change is minimal, well-targeted, and includes proper test coverage. No compatibility or performance concerns.

@codecov-commenter

codecov-commenter commented Jul 17, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 25.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 51.02%. Comparing base (476b870) to head (044a934).
⚠️ Report is 19 commits behind head on develop.

Files with missing lines Patch % Lines
...rocketmq/remoting/netty/NettyRemotingAbstract.java 14.28% 3 Missing and 3 partials ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop   #10621      +/-   ##
=============================================
+ Coverage      50.26%   51.02%   +0.75%     
- Complexity     14610    14920     +310     
=============================================
  Files           1391     1391              
  Lines         103488   103775     +287     
  Branches       13562    13614      +52     
=============================================
+ Hits           52017    52947     +930     
+ Misses         45227    44559     -668     
- Partials        6244     6269      +25     

☔ 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.

@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.

Review by github-manager-bot (Follow-up)

Thanks for addressing the suggestion! The added comment in LocalRemotingCommand.createRequestCommand() clearly explains why the timer is initialized there.

Changes in a6016f94

  • Added inline comment explaining that local requests bypass NettyDecoder — exactly as suggested.

Verdict

✅ Looks good. No further concerns.

@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

Defensive fix with proper validation and test coverage. LGTM.


Automated review by github-manager-bot

@majialoong

Copy link
Copy Markdown
Contributor Author

Hi @RongtongJin @lizhimins @ShannonDing , could you please help review this PR when you have a moment?

I ran into this NPE during some performance testing in local proxy mode, it triggers on every async response (send/pop), causing frequent NPE logs and missing RPC latency metrics. Even though local mode isn't commonly used, I think it's still worth fixing. Thanks!

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.

[Bug] Fix NPE when recording RPC latency for local proxy requests

3 participants