On Fri, 13 Nov 2026 11:41:59 GMT, Michael McMahon <[email protected]> wrote:
>> Sendao Yan has updated the pull request with a new target base due to a
>> merge or a rebase. The incremental webrev excludes the unrelated changes
>> brought in by the merge/rebase. The pull request contains seven additional
>> commits since the last revision:
>>
>> - Merge branch 'openjdk:master' into jbs8380124
>> - Merge branch 'openjdk:master' into jbs8380124
>> - Merge branch 'openjdk:master' into jbs8380124
>> - Merge branch 'openjdk:master' into jbs8380124
>> - Merge branch 'openjdk:master' into jbs8380124
>> - Merge branch 'openjdk:master' into jbs8380124
>> - 8380124: Test java/net/InetAddress/ptr/Lookup.java fails intermittently
>> due to reverse lookup failed
>
> test/jdk/java/net/InetAddress/ptr/Lookup.java line 115:
>
>> 113: strs = tmp.split(":");
>> 114: addr = strs[0];
>> 115: ipv4Reversed = strs[1];
>
> Some test runs are failing with ArrayIndexOutOfBounds when accessing the
> second element of strs[]. I guess this can happen if the sub process returns
> a String like "192.0.43.7:" I don't fully understand the reason, but it might
> be better to move this reference to after the new check. Maybe the same
> applies to the code that sets ipv4name as well.
Thanks Michael. Confirmed — I was able to reproduce this.
The sub-process prints `<address>:<host name>`. If the reverse lookup returns
an empty name, the output is `192.0.43.7:`. `String.split(":")` uses limit 0,
which means it drops the trailing empty string, so `strs` has length 1 and
`strs[1]` throws `ArrayIndexOutOfBoundsException` before the `addr.equals(...)`
check is ever reached. I moved the `strs[1]` access behind a length check in
both places and treat it the same as the other reverse-lookup failures, i.e.
skip the test:
String[] strs = tmp.split(":");
addr = strs[0];
if (strs.length < 2) {
// the sub process returned "<address>:" without a host name,
// and String.split() drops the trailing empty string
throw new SkippedException(addr + " can't reverse resolved to host - test
skipped.");
}
ipv4Name = strs[1];
and the same for the second lookup that sets `ipv4Reversed`.
Testing:
- Ran the patched test 20 times on linux-x64 and all runs passed, and on this
machine the lookup resolves normally so none of them were skipped.
- Reproduced the failure you described by forcing the sub-process to print
`<address>:` (i.e. an empty host name). The previous version then fails with
exactly that AIOOBE (`Index 1 out of bounds for length 1`), while the patched
version skips at the first check. Forcing only the reverse lookup to return an
empty name makes it skip at the second check as well.
Updated the PR with a new commit.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/30259#discussion_r4564545374