itxaiohanglover opened a new pull request, #10592:
URL: https://github.com/apache/rocketmq/pull/10592

   ## Which Issue(s) This PR Fixes
   
   Fixes #10591
   
   ## Brief Description
   
   When a gRPC client connects to the Proxy via IPv6, the remote address is 
formatted as `[240e:...:2]:44880` (with brackets). The 
`NetworkUtil.string2SocketAddress` method splits on the last `:` to separate 
host and port, but the host part retains the surrounding `[]` brackets.
   
   When `new InetSocketAddress("[240e:...:2]", port)` is constructed with a 
bracketed host, Java's `InetAddress.getByName()` fails to resolve it, causing 
`getAddress()` to return `null`. This `null` propagates to 
`CommitLog.asyncPutMessage` (line 994) where `bornSocketAddress.getAddress()` 
triggers a `NullPointerException`.
   
   **Root cause**: `string2SocketAddress` does not strip IPv6 brackets before 
constructing `InetSocketAddress`.
   
   **Fix**: Strip surrounding `[]` from the host part before calling `new 
InetSocketAddress(host, port)`.
   
   ## How Did You Test This Change?
   
   Added `NetworkUtilTest` with 5 test cases:
   
   - `testString2SocketAddressIPv4` — existing IPv4 behavior unchanged
   - `testString2SocketAddressIPv6WithBrackets` — reproduces the issue: 
`[240e:341:6246:c700:c4ad:e645:459e:2]:44880` now resolves correctly with 
non-null `getAddress()`
   - `testString2SocketAddressIPv6Loopback` — `[::1]:8080` resolves correctly
   - `testSocketAddress2StringIPv4` — round-trip conversion unchanged
   - `testNormalizeAndDenormalizeHostAddress` — bracket normalize/denormalize 
helpers
   
   ```
   mvn -pl common -Dtest=NetworkUtilTest test
   Tests run: 8, Failures: 0, Errors: 0, Skipped: 0
   BUILD SUCCESS
   ```


-- 
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]

Reply via email to