Skip to content

[Enhancement] Fix NPE when isAsyncSendEnable is false in transaction metrics recording #9750

@RongtongJin

Description

@RongtongJin

Before Creating the Enhancement Request

  • I have confirmed that this should be classified as an enhancement rather than a bug/feature.

Summary

A potential NPE (Null Pointer Exception) issue exists in the transaction metrics recording logic in SendMessageProcessor.java when isAsyncSendEnable is configured to false.

Motivation

Problem Details:
Location: broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java line 359
Root Cause: In synchronous send mode (isAsyncSendEnable = false), the transaction metrics recording condition check is incomplete
Specific Issue: When sendTransactionPrepareMessage is false, the code still attempts to access transaction-related metrics, potentially causing NPE
Reproduction Steps:
Configure isAsyncSendEnable = false
Send non-transactional messages
Observe logs for potential NPE occurrences
Expected Behavior:
Transaction metrics should only be recorded when processing transaction prepare messages, avoiding access to transaction-related services in non-transaction scenarios.
Impact Scope:
Message processing in synchronous send mode
Accuracy of transaction metrics statistics
System stability

Describe the Solution You'd Like

Fix NPE when isAsyncSendEnable is false in transaction metrics recording

Describe Alternatives You've Considered

No

Additional Context

No

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions