btlqql opened a new pull request, #10743:
URL: https://github.com/apache/rocketmq/pull/10743
### Motivation
Three edge-case bugs found by code review (verified against the current
develop branch):
1. **`NetworkUtil.socketAddress2String` NPE**
(`common/src/main/java/org/apache/rocketmq/common/utils/NetworkUtil.java`)
`InetSocketAddress.getAddress()` returns `null` when the hostname could
not be resolved, so `getAddress().getHostAddress()` threw
`NullPointerException`. This util is used across broker/namesrv/tools. Fall
back to `getHostString()` when the address is null.
2. **`NetworkUtil.string2SocketAddress` StringIndexOutOfBoundsException**
An address without `:` makes `lastIndexOf(":")` return `-1`, and
`substring(0, -1)` throws `StringIndexOutOfBoundsException`. Throw a clear
`IllegalArgumentException` instead.
3. **`IndexService.getTotalSize` concurrent read**
(`store/src/main/java/org/apache/rocketmq/store/index/IndexService.java`)
`indexFileList` is a plain `ArrayList` guarded by `readWriteLock` in
every other accessor, but `getTotalSize` read it without the lock. A concurrent
`destroy()`/`deleteExpiredFile()` could clear the list between the `isEmpty()`
check and `get(0)`, causing `IndexOutOfBoundsException`. Acquire the read lock.
### Verification
`mvn -pl broker -am compile` passes on the build server.
### Diff
2 files changed, +15 / -5.
--
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]