RFR: 8272215: Add InetAddress methods for parsing IP address literals [v2]
Aleksei Efimov
aefimov at openjdk.org
Tue Oct 10 15:13:20 UTC 2023
On Mon, 9 Oct 2023 07:12:48 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:
>> Aleksei Efimov has updated the pull request incrementally with two additional commits since the last revision:
>>
>> - updates for Inet6Address.ofLiteral return type, javadoc and the regression test
>> - add null checks and NPE to methods javadoc
>
> src/java.base/share/classes/java/net/Inet4Address.java line 181:
>
>> 179: /**
>> 180: * Parses string with an IPv4 address literal.
>> 181: * If string doesn't contain a valid literal - null is returned.
>
> This sentence is a bit confusing, given the implementation details of this method. I think `null` is only returned if `throwIAE` is false?
Thank you for spotting it. I have updated the javadoc of the `parseAddressString` method to contain all three possible scenarios:
* If string contains a non-parsable literal and {@code throwIAE} is set to {@code false}
* - {@code null} is returned.
* If string contains a non-parsable literal and {@code throwIAE} is set to {@code true}
* - {@code IllegalArgumentException} is thrown.
* If string contains an {@linkplain IPAddressUtil#validateNumericFormatV4(String, boolean)
* ambiguous literal} - {@code IllegalArgumentException} is thrown irrelevant to
* {@code throwIAE} value.
> src/java.base/share/classes/sun/net/util/IPAddressUtil.java line 141:
>
>> 139: * @param src input string
>> 140: * @param throwIAE {@code "true"} - throw {@code IllegalArgumentException} when cannot be parsed as IPv4 address string;
>> 141: * {@code "false"} - throw {@code "IllegalArgumentException"} only when IPv4 address string is ambiguous.
>
> Are these double quotes around `true`, `false`, `null` and `IllegalArgumentException` intentional? It seems odd to have those double quotes when (rightly) using `{@code}`.
Nope, there are not intentional - a leftover from the fix prototyping stage. Will remove them.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15775#discussion_r1352771068
PR Review Comment: https://git.openjdk.org/jdk/pull/15775#discussion_r1352772971
More information about the net-dev
mailing list