apache / apache/rocketmq

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

Open
#10,620 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
22.6k
Forks
12k
Avg merge
3d 1h
Merged PRs (30d)
27

Description

### 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`.

Image

### 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_

Contributor guide

Open the contributing guide

Research direction

Start by tracing LocalRemotingCommand and NettyRemotingAbstract.writeResponse, then compare the request path with NettyDecoder, where processTimer is initialized. Reproduce the issue in RocketMQ Proxy Local mode through the gRPC endpoint; done means the response path no longer throws a NullPointerException and RPC latency is recorded successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
grpc, java
Domain
backend, observability
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.