btlqql opened a new pull request, #4683:
URL: https://github.com/apache/rocketmq-dashboard/pull/4683
<!-- Base branch: `rocketmq-studio`, the RocketMQ Studio trunk. -->
### Which Issue(s) This PR Fixes
- Fixes #4554
### Brief Description
`BrokerTopologyGuards.validatedBrokerAddr` decided whether the broker
embedded in a physical-offset
msgId belongs to the selected instance with an exact `Set.contains` against
the addresses from
`examineBrokerClusterInfo()`. Those addresses are the strings the brokers
registered with, while
`MessageDecoder.decodeMessageId` always yields a numeric address
(`InetAddress.getByAddress`, no
reverse lookup). On a cluster whose brokers register with a hostname
(`brokerIP1=broker-0`, the style
of the bundled `deploy/rocketmq/conf/broker-0.conf`), the two never match,
so the guard rejected every
offset id and the lookup returned an empty result.
The guard now falls back to comparing the resolved addresses (same port
required) before rejecting, so
a numeric address that resolves to a registered hostname endpoint is
accepted. Unresolvable or
unrelated endpoints are still rejected, and the exact-match fast path is
unchanged.
### How Did You Test This Change?
The regression test fails on the unmodified base (only the new test fails;
the three negative
controls already pass), and passes with the fix:
```
$ cd server && mvn -B -ntp test -Dtest=BrokerTopologyGuardsTest # before
the fix
[ERROR] Tests run: 4, Failures: 1, Errors: 0, Skipped: 0, Time elapsed:
2.329 s <<< FAILURE! -- in
org.apache.rocketmq.studio.provider.apache.BrokerTopologyGuardsTest
[ERROR]
org.apache.rocketmq.studio.provider.apache.BrokerTopologyGuardsTest.acceptsAnOffsetIdWhoseBrokerIsRegisteredWithAHostname
-- Time elapsed: 0.037 s <<< FAILURE!
at
org.apache.rocketmq.studio.provider.apache.BrokerTopologyGuardsTest.acceptsAnOffsetIdWhoseBrokerIsRegisteredWithAHostname(BrokerTopologyGuardsTest.java:43)
[ERROR] Tests run: 4, Failures: 1, Errors: 0, Skipped: 0
[INFO] BUILD FAILURE
```
```
$ cd server && mvn -B -ntp test
-Dtest=BrokerTopologyGuardsTest,RocketMQMessageProviderTest,RocketMQDLQProviderTest
[INFO] You have 0 Checkstyle violations.
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0 -- in
org.apache.rocketmq.studio.provider.apache.BrokerTopologyGuardsTest
[INFO] Tests run: 39, Failures: 0, Errors: 0, Skipped: 0 -- in
org.apache.rocketmq.studio.provider.apache.RocketMQDLQProviderTest
[INFO] Tests run: 54, Failures: 0, Errors: 0, Skipped: 0 -- in
org.apache.rocketmq.studio.provider.apache.RocketMQMessageProviderTest
[INFO] Tests run: 97, Failures: 0, Errors: 0, Skipped: 0
[INFO] BUILD SUCCESS
```
The test drives the guard through its public entry points with a fixture
`ClusterInfo` (a broker
registered as `localhost:10911`): the offset id built from the resolved
address is accepted and
`validatedBrokerAddr` returns that numeric address, while an address outside
the topology, a
non-matching port and an unresolvable hostname are still rejected.
`RocketMQMessageProviderTest` and
`RocketMQDLQProviderTest` cover the two consumers of the guard and stay
green.
### 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
- [x] Documentation touched where behaviour changed (no user-facing docs for
this guard)
--
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]