[ISSUE #10419] Fix NPE when class filter route data is missing#10420
[ISSUE #10419] Fix NPE when class filter route data is missing#10420yin-bo-Final wants to merge 2 commits into
Conversation
oss-sentinel-ai
left a comment
There was a problem hiding this comment.
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 ongetFilterServerTable()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] ✅
testPullKernelImplWithMissingTopicRouteDataForClassFiltervalidates the fix well — emptyConcurrentHashMapensuresget(topic)returns null, and the assertion checks forMQClientExceptionwith 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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Review by github-manager-bot
Summary
Adds null checks for topicRouteData and topicRouteData.getFilterServerTable() in PullAPIWrapper.computePullFromWhichFilterServer() to prevent NPE when class filter route data is missing.
Findings
- [Critical]
PullAPIWrapper.java:302— Without the null check,topicRouteData.getFilterServerTable()throws NPE whentopicRouteDatais null (route not yet populated) or whengetFilterServerTable()returns null (no filter server registered). The fix is correct and minimal. - [Info]
PullAPIWrapperTest.java— Excellent test coverage: 4 test cases covering null route data, null filter server table, missing broker entry, and empty list. Each scenario is isolated and verifies the expected fallback behavior.
Suggestions
No concerns. This is a clean, defensive null check with thorough test coverage.
Verdict: LGTM.
Automated review by github-manager-bot
Which Issue(s) This PR Fixes
Brief Description
This PR avoids a potential
NullPointerExceptioninPullAPIWrapper#computePullFromWhichFilterServerwhen 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 existingMQClientExceptionpath.How Did You Test This Change?
mvn -pl client -Dtest=org.apache.rocketmq.client.impl.consumer.PullAPIWrapperTest -Djacoco.skip=true testThe test passed with
Tests run: 8, Failures: 0, Errors: 0, Skipped: 0.