Skip to content

[ISSUE #10419] Fix NPE when class filter route data is missing#10420

Open
yin-bo-Final wants to merge 2 commits into
apache:developfrom
yin-bo-Final:fix-pullapiwrapper-class-filter-npe
Open

[ISSUE #10419] Fix NPE when class filter route data is missing#10420
yin-bo-Final wants to merge 2 commits into
apache:developfrom
yin-bo-Final:fix-pullapiwrapper-class-filter-npe

Conversation

@yin-bo-Final
Copy link
Copy Markdown

Which Issue(s) This PR Fixes

Brief Description

This PR avoids a potential NullPointerException in PullAPIWrapper#computePullFromWhichFilterServer when class filter is enabled but the local topic route table does not contain route data for the target topic.

Instead of dereferencing a missing TopicRouteData, the code falls through to the existing MQClientException path.

How Did You Test This Change?

  • Added a targeted unit test for missing topic route data.
  • Ran:
mvn -pl client -Dtest=org.apache.rocketmq.client.impl.consumer.PullAPIWrapperTest -Djacoco.skip=true test

The test passed with Tests run: 8, Failures: 0, Errors: 0, Skipped: 0.

Copy link
Copy Markdown

@oss-taishan-ai oss-taishan-ai left a comment

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 PullAPIWrapper#computePullFromWhichFilterServer when topicRouteData is null, allowing the method to fall through to the existing MQClientException error path.

Findings

  • [Correctness] ✅ The null check on topicRouteData (line 302) correctly addresses the NPE reported in #10419. The additional null check on getFilterServerTable() is a good defensive measure.
  • [Correctness] ✅ The control flow after the fix is correct: when route data or filter server table is missing, the method falls through to the existing MQClientException("Find Filter Server Failed, ...") at the bottom of the method.
  • [Tests]testPullKernelImplWithMissingTopicRouteDataForClassFilter validates the fix well — empty ConcurrentHashMap ensures get(topic) returns null, and the assertion checks for MQClientException with the expected message.
  • [Compatibility] ✅ No public API changes. Backward compatible.

Verdict

LGTM. Clean, minimal fix that aligns with the existing error handling pattern. Test coverage is adequate.


Automated review by github-manager-bot

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jun 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 47.94%. Comparing base (2a9560c) to head (65c20fc).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop   #10420      +/-   ##
=============================================
- Coverage      48.05%   47.94%   -0.11%     
+ Complexity     13303    13279      -24     
=============================================
  Files           1377     1377              
  Lines         100611   100614       +3     
  Branches       12991    12993       +2     
=============================================
- Hits           48347    48240     -107     
- Misses         46348    46431      +83     
- Partials        5916     5943      +27     

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

Copy link
Copy Markdown
Contributor

@RongtongJin RongtongJin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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] PullAPIWrapper throws NPE when class filter topic route data is missing

4 participants