Skip to content

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

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

[ISSUE #10620] Fix NPE when recording RPC latency for local proxy requests#10621
majialoong wants to merge 2 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:35Stopwatch.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

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 48.21%. Comparing base (45254d5) to head (a6016f9).

Additional details and impacted files
@@              Coverage Diff              @@
##             develop   #10621      +/-   ##
=============================================
- Coverage      48.31%   48.21%   -0.10%     
+ Complexity     13480    13446      -34     
=============================================
  Files           1380     1380              
  Lines         101009   101010       +1     
  Branches       13080    13080              
=============================================
- Hits           48799    48707      -92     
- Misses         46258    46321      +63     
- Partials        5952     5982      +30     

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

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