btlqql opened a new pull request, #4688:
URL: https://github.com/apache/rocketmq-dashboard/pull/4688
<!-- Base branch: `rocketmq-studio`, the RocketMQ Studio trunk. -->
### Brief Description
`RocketMQAdminClientImpl.getTopic` maps every failure of
`admin.examineTopicRouteInfo(name)` to
`500 "Failed to get topic: ..."`, so the `404 "Topic not found: <name>"`
branches it declares for an
empty route were unreachable in the case that actually happens: a topic that
was never created makes
the NameServer answer `TOPIC_NOT_EXIST`, and the client re-throws that as
`MQClientException(17, "No topic route info in name server for the topic:
X")` instead of returning
null. Asking for the detail of a non-existent topic therefore surfaced as a
server error.
The catch block now grades `TOPIC_NOT_EXIST` from the cause chain to the
same `404 "Topic not found"`
the method already returns for an empty route, using the package-wide
`MqResponseCodes` helper that
`RocketMQMessageProvider`, `RocketMQClientProvider`, `RocketMQDLQProvider`
and
`RocketMQMetadataProvider` use for this response code. Other failures keep
the existing 500.
### How Did You Test This Change?
The regression test fails on the unmodified base and passes with the fix:
```
$ cd server && mvn -B -ntp test -Dtest=RocketMQAdminClientImplTest #
before the fix
[ERROR] Tests run: 65, Failures: 1, Errors: 0, Skipped: 0, Time elapsed:
5.524 s <<< FAILURE! -- in
org.apache.rocketmq.studio.provider.apache.RocketMQAdminClientImplTest
[ERROR]
RocketMQAdminClientImplTest.getTopicReturnsNotFoundWhenTheNameServerHasNoRoute
-- Time elapsed: 0.034 s <<< FAILURE!
but was: 500
[ERROR]
RocketMQAdminClientImplTest.getTopicReturnsNotFoundWhenTheNameServerHasNoRoute:171
[INFO] BUILD FAILURE
```
```
$ cd server && mvn -B -ntp test -Dtest=RocketMQAdminClientImplTest
[INFO] You have 0 Checkstyle violations.
[INFO] Tests run: 65, Failures: 0, Errors: 0, Skipped: 0, Time elapsed:
4.709 s -- in
org.apache.rocketmq.studio.provider.apache.RocketMQAdminClientImplTest
[INFO] Tests run: 65, Failures: 0, Errors: 0, Skipped: 0
[INFO] BUILD SUCCESS
```
The test stubs `examineTopicRouteInfo` with the exception the 5.5.0 client
really throws for an
unknown topic (`javap` on `MQClientAPIImpl.getTopicRouteInfoFromNameServer`
shows the
`TOPIC_NOT_EXIST` branch ending in `new
MQClientException(response.getCode(), response.getRemark())`,
and `DefaultMQAdminExtImpl.examineTopicRouteInfo` returns that call
directly), then asserts the
`BusinessException(404, "Topic not found: orders")`. The neighbouring
`getTopicReturnsNotFoundWhenAllQueueDataIsNull` and
`getTopicUsesFirstUsableQueueData` tests still
pass, so the success path and the empty-route path are unchanged.
The two files here are also touched by other open PRs
(`RocketMQAdminClientImpl.java` and its test),
but this change is a self-contained hunk at the `getTopic` catch block (line
~119-129) and test
insertion after `getTopicReturnsNotFoundWhenAllQueueDataIsNull`; no other
PR's hunks touch that
range (checked with the pull-request files API before opening).
### Checklist
- [x] One coherent change; unrelated modifications are not bundled in
- [x] Commit subject follows Conventional Commits (`fix:`)
- [x] Tests added or updated for non-trivial changes, test methods named
`...Test`
- [x] New UI text has both Chinese and English entries under `web/src/i18n/`
(no UI text changed)
- [x] Architecture constraints stay green (`mvn test` runs the ArchUnit
checks)
- [x] New source files carry the ASF license header (no new source file)
- [x] Documentation touched where behaviour changed (status-code semantics
unchanged elsewhere)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]