weidong-qi opened a new pull request, #11484: URL: https://github.com/apache/rocketmq/pull/11484
### Which Issue(s) This PR Fixes - Fixes #11483 ### Brief Description `NettyRemotingClient#getProxy` called `RemotingHelper#ipInCIDR` for every configured CIDR except the literal `0.0.0.0/0`. `ipInCIDR` only parses dotted IPv4 literals, so a target given as a hostname (e.g. `namesrv.example.com:9876`) or an IPv6 literal threw `NumberFormatException`, and the connection attempt failed. This change runs the CIDR check only when the host is a valid IPv4 literal (`IPAddressUtils#isValidIPv4`). Other hosts skip the specific CIDR entries and can still match the `0.0.0.0/0` catch-all entry. `ipInCIDR` itself is untouched, so this does not overlap with #11068. ### How Did You Test This Change? Added three cases to `NettyRemotingClientTest`: - `testGetProxyMatchesIpv4AddressInCidr`: IPv4 inside / outside `10.0.0.0/8` keeps its current behavior. - `testGetProxySkipsCidrForNonIpv4Host`: `namesrv.example.com:9876` and `[fe80::1]:9876` return no proxy instead of throwing. - `testGetProxyDefaultCidrMatchesHostname`: a hostname still matches the `0.0.0.0/0` entry. Before the fix, `testGetProxySkipsCidrForNonIpv4Host` fails with `NumberFormatException: For input string: "namesrv"`. After the fix all 19 tests in `NettyRemotingClientTest` pass, and `mvn -pl remoting validate` reports 0 Checkstyle violations. -- 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]
