RFR: 8332686: InetAddress.ofLiteral can throw StringIndexOutOfBoundsException [v2]

Aleksei Efimov aefimov at openjdk.org
Tue Dec 3 17:32:13 UTC 2024


> The proposed change fixes `InetAddress.ofLiteral` and `Inet6Address.ofLiteral` to throw `IllegalArgumentException` instead of `StringIndexOutOfBoundsException` when an empty IP addres literal string is specified.   
> The `Inet4Address.ofLiteral` correctly throws `IllegalArgumentException` when a literal cannot be parsed as an IPv4 address literal. It was addressed before in [JDK-8315767](https://bugs.openjdk.org/browse/JDK-8315767) fix.
> 
> Testing: the modified `OfLiteralTest` test and other tests from `jdk-tier1` to `jdk-tier3` tiers

Aleksei Efimov has updated the pull request incrementally with two additional commits since the last revision:

 - IA.ofLiteral - no need to try parsing as IPv4 and IPv6 literal if string is empty.
 - Add test cases for blank string literals

-------------

Changes:
  - all: https://git.openjdk.org/jdk/pull/22518/files
  - new: https://git.openjdk.org/jdk/pull/22518/files/4d02a617..2e509b89

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=22518&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=22518&range=00-01

  Stats: 10 lines in 2 files changed: 9 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/22518.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/22518/head:pull/22518

PR: https://git.openjdk.org/jdk/pull/22518


More information about the net-dev mailing list