You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "majialoong (via GitHub)" <gi...@apache.org> on 2026/07/17 05:01:12 UTC

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

majialoong opened a new issue, #10620:
URL: https://github.com/apache/rocketmq/issues/10620

   ### Before Creating the Bug Report
   
   - [x] I found a bug, not just asking a question, which should be created in [GitHub Discussions](https://github.com/apache/rocketmq/discussions).
   
   - [x] I have searched the [GitHub Issues](https://github.com/apache/rocketmq/issues) and [GitHub Discussions](https://github.com/apache/rocketmq/discussions)  of this repository and believe that this is not a duplicate.
   
   - [x] I have confirmed that this bug belongs to the current repository, not other repositories of RocketMQ.
   
   
   ### Runtime platform environment
   
   All
   
   ### RocketMQ version
   
   5.x 
   
   ### JDK Version
   
   All
   
   ### Describe the Bug
   
   In Local Proxy mode, `LocalRemotingCommand` does not initialize `processTimer` because the request does not pass through `NettyDecoder`. 
   
   This causes a `NullPointerException` in the `ChannelFutureListener` of `NettyRemotingAbstract.writeResponse` when recording the RPC latency.
   
   ### Steps to Reproduce
   
   1. Start RocketMQ Proxy in Local mode.
   2. Send a message through the gRPC endpoint.
   3. Inspect `NettyRemotingAbstract.writeResponse` when the response is written.
   4. Observe that `request.getProcessTimer()` is `null`.
   
   <img width="752" height="407" alt="Image" src="https://github.com/user-attachments/assets/2a88fcc6-9196-4a7a-af3f-1cb6c537f54b" />
   
   
   ### What Did You Expect to See?
   
   The local request should have an initialized process timer, and the RPC latency metric should be recorded successfully.
   
   ### What Did You See Instead?
   
   A `NullPointerException` occurs when calling `request.getProcessTimer().elapsed(...)`. 
   
   ### Additional Context
   
   _No response_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] Fix NPE when recording RPC latency for local proxy requests [rocketmq]

Posted by "RockteMQ-AI (via GitHub)" <gi...@apache.org>.
RockteMQ-AI commented on issue #10620:
URL: https://github.com/apache/rocketmq/issues/10620#issuecomment-4999536831

   **Issue Evaluation**
   
   Category: `type/bug` | Status: **Confirmed**
   
   The reported issue has been verified against the current codebase.
   
   **Root Cause:** `processTimer` is declared in `RemotingCommand` (line 100) but never initialized in the constructor. The only initialization point is `NettyDecoder` (line 42/49), which creates a `Stopwatch.createStarted()` and sets it on the decoded command. `LocalRemotingCommand` bypasses the Netty pipeline entirely — it is constructed in-process by the proxy layer, so `processTimer` remains `null`.
   
   **Crash Sites:** `NettyRemotingAbstract.writeResponse` dereferences `request.getProcessTimer().elapsed(...)` unconditionally at 3 locations (lines 250, 267, 279), all without null guards.
   
   **Impact:** Any gRPC request through Local Proxy mode will trigger NPE when the response is written back, affecting RPC latency metrics recording and potentially crashing the response path.
   
   **Severity:** High — affects all Local Proxy mode users.
   
   **Suggested Fix:** Initialize `processTimer` in `RemotingCommand` constructor, and/or add null guards at the `writeResponse` call sites.
   
   An automated fix proposal will be generated. Reply `/approve` to proceed with PR generation.
   
   ---
   *Automated evaluation by github-manager-bot*


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org