Skip to content

[ISSUE #11423] fix(proxy): report a missing local topic as TOPIC_NOT_EXIST - #11424

Open
iloveeyjafjalla wants to merge 1 commit into
apache:developfrom
iloveeyjafjalla:codex/local-route-topic-not-exist
Open

iloveeyjafjalla wants to merge 1 commit into
apache:developfrom
iloveeyjafjalla:codex/local-route-topic-not-exist

Conversation

@iloveeyjafjalla

Copy link
Copy Markdown
Contributor

Which Issue(s) This PR Fixes

Brief Description

LocalTopicRouteService.getCurrentMessageQueueView looked 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 a NullPointerException while building the queue data:

TopicConfig topicConfig = this.brokerController.getTopicConfigManager().getTopicConfigTable().get(topic);
return new MessageQueueView(topic, toTopicRouteData(topicConfig), null);   // topicConfig may be null -> NPE at topicConfig.getPerm()

The cluster implementation of the same method already answers with a client error — getAllMessageQueueView → TopicRouteService.getCacheMessageQueueWrapper throws MQClientException(ResponseCode.TOPIC_NOT_EXIST, "No topic route info in name server for the topic: …"), and ClusterTopicRouteServiceTest pins that behaviour. This change mirrors it for LOCAL mode:

if (topicConfig == null) {
    throw new MQClientException(ResponseCode.TOPIC_NOT_EXIST,
        "No topic route info in local broker for the topic: " + topic);
}

so the callers can produce their designed responses instead of an internal error — ConsumerProcessor.popMessage reaches FORBIDDEN, "no readable queue" handling and ProducerProcessor.sendMessage (FORBIDDEN, "no writable queue") for topics that exist, while a genuinely missing topic is reported as TOPIC_NOT_EXIST.

How Did You Test This Change?

New test LocalTopicRouteServiceTest#testGetCurrentMessageQueueViewForUnknownTopic: calls getCurrentMessageQueueView for a topic that is not in the broker's topic config table and asserts a MQClientException with ResponseCode.TOPIC_NOT_EXIST (the existing testGetCurrentMessageQueueView covers the topic-present case).

Results on Temurin JDK 8 (the JDK CI uses), base a7edeecfb plus this patch:

  • before the fix: java.lang.AssertionError — the call throws NullPointerException instead of MQClientException
  • after the fix: LocalTopicRouteServiceTest — Tests run: 3, Failures: 0, Errors: 0
  • mvn -B -ntp -pl proxy clean package -Dtest='!ProxyChannelTest': BUILD SUCCESS, 453 tests / 0 failures / 4 skipped, You have 0 Checkstyle violations., BugInstance size is 0

Disclosure: ProxyChannelTest#testWriteAndFlush is excluded from that run because it fails on the unmodified base as well (documented in earlier local verification); skipAfterFailureCount=1 is 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.

Copilot AI balanced review requested due to automatic review settings October 13, 2026 14:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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

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 the get(topic) lookup and before toTopicRouteData(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 uses catchThrowableOfType and 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

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] LOCAL-mode proxy throws NullPointerException for a topic that is not in the broker's topic config table

3 participants