Skip to content

[ISSUE #10931] Initialize cluster transaction address mapping - #10932

Open
Aias00 wants to merge 1 commit into
apache:developfrom
Aias00:fix/cluster-transaction-address-map
Open

[ISSUE #10931] Initialize cluster transaction address mapping#10932
Aias00 wants to merge 1 commit into
apache:developfrom
Aias00:fix/cluster-transaction-address-map

Conversation

@Aias00

@Aias00 Aias00 commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Initialize the cluster transaction address-to-broker mapping with an empty map so a transaction sent before the first heartbeat scan does not dereference a null map.

Validation

  • mvn -pl proxy -Dtest=ClusterTransactionServiceTest test

Closes #10931

Signed-off-by: liuhy <liuhongyu@apache.org>

@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

LGTM. This is a clean defensive fix that prevents NPE when accessing the broker address map before the first heartbeat scan.

Key change:

  • Initialize brokerAddrNameMapRef with Collections.emptyMap() instead of null
  • Thread-safe immutable empty map is appropriate for AtomicReference

Test coverage:

  • New test testAddTransactionDataByBrokerAddrBeforeFirstHeartbeat validates the edge case
  • Verifies that accessing the map before heartbeat scan returns null gracefully instead of throwing NPE

Minimal, focused fix with proper validation.


Automated review by github-manager-bot

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 48.52%. Comparing base (293f588) to head (856d25d).

Additional details and impacted files
@@              Coverage Diff              @@
##             develop   #10932      +/-   ##
=============================================
- Coverage      48.62%   48.52%   -0.10%     
+ Complexity     13692    13657      -35     
=============================================
  Files           1381     1381              
  Lines         101464   101465       +1     
  Branches       13187    13187              
=============================================
- Hits           49337    49240      -97     
- Misses         46142    46219      +77     
- Partials        5985     6006      +21     

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

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] Cluster transaction service throws before broker address mapping is initialized

3 participants