Repository navigation
[ISSUE #11423] fix(proxy): report a missing local topic as TOPIC_NOT_EXIST - #11424
iloveeyjafjalla wants to merge 1 commit into
Conversation
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Review by github-manager-bot
Summary
Fixes NPE in LocalTopicRouteService.getCurrentMessageQueueView when a topic is not found in the local broker's config table, replacing it with a proper MQClientException(TOPIC_NOT_EXIST) — consistent with the cluster-mode behavior.
Findings
-
[Info]
LocalTopicRouteService.java:58— The null check is correctly placed immediately after theget(topic)lookup and beforetoTopicRouteData(topicConfig). Clean and minimal. -
[Info]
LocalTopicRouteService.java:59— Error message includes the topic name, which is helpful for debugging. Consider also logging the event at WARN level if the proxy module has a logger available, so operators can detect misconfigured clients attempting to consume from non-existent topics. This is optional and not a blocker. -
[Info]
LocalTopicRouteServiceTest.java:95-101— Test correctly usescatchThrowableOfTypeand verifies both the exception type and response code. Good coverage of the negative path.
Assessment
| Dimension | Verdict |
|---|---|
| Correctness | ✅ Null check prevents NPE; error code matches cluster-mode semantics |
| Performance | ✅ No concern — single null check |
| Tests | ✅ New test covers unknown-topic path; existing test covers happy path |
| Compatibility | ✅ Improves error reporting without breaking API contract |
This is a well-prepared fix. LGTM.
Automated review by github-manager-bot
Which Issue(s) This PR Fixes
Brief Description
LocalTopicRouteService.getCurrentMessageQueueViewlooked the topic up in the local broker's topic config table and passed the result straight into the route-data builder, so a topic that is not in the table produced aNullPointerExceptionwhile building the queue data:The cluster implementation of the same method already answers with a client error —
getAllMessageQueueView→TopicRouteService.getCacheMessageQueueWrapperthrowsMQClientException(ResponseCode.TOPIC_NOT_EXIST, "No topic route info in name server for the topic: …"), andClusterTopicRouteServiceTestpins that behaviour. This change mirrors it for LOCAL mode:so the callers can produce their designed responses instead of an internal error —
ConsumerProcessor.popMessagereachesFORBIDDEN, "no readable queue"handling andProducerProcessor.sendMessage(FORBIDDEN, "no writable queue") for topics that exist, while a genuinely missing topic is reported asTOPIC_NOT_EXIST.How Did You Test This Change?
New test
LocalTopicRouteServiceTest#testGetCurrentMessageQueueViewForUnknownTopic: callsgetCurrentMessageQueueViewfor a topic that is not in the broker's topic config table and asserts aMQClientExceptionwithResponseCode.TOPIC_NOT_EXIST(the existingtestGetCurrentMessageQueueViewcovers the topic-present case).Results on Temurin JDK 8 (the JDK CI uses), base
a7edeecfbplus this patch:java.lang.AssertionError— the call throwsNullPointerExceptioninstead ofMQClientExceptionLocalTopicRouteServiceTest—Tests run: 3, Failures: 0, Errors: 0mvn -B -ntp -pl proxy clean package -Dtest='!ProxyChannelTest':BUILD SUCCESS, 453 tests / 0 failures / 4 skipped,You have 0 Checkstyle violations.,BugInstance size is 0Disclosure:
ProxyChannelTest#testWriteAndFlushis excluded from that run because it fails on the unmodified base as well (documented in earlier local verification);skipAfterFailureCount=1is configured for this module, so leaving it in would hide the rest of the suite.This change was prepared with AI assistance (analysis, patch and test drafting); the diff and every result above were reproduced locally by running the module's tests against the base commit and the patched tree.