RFR: 8272215: Add InetAddress methods for parsing IP address literals [v2]

Alan Bateman alanb at openjdk.org
Mon Oct 9 07:15:09 UTC 2023


On Mon, 9 Oct 2023 07:00:08 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:

> The new APIs are proposing to throw an `IllegalArgumentException` if the passed literal is not an IP address literal. That seems logical. However, the existing `getByAddress(byte[] ...)` API which accepts a byte form of the raw IP address, currently throws `UnknownHostException` in the case where the IP address isn't of a valid length. Should we consider throwing `UnknownHostException` from these new APIs too? I prefer `IllegalArgumentException` in these new APIs, but `UnknownHostException` might be something that would need to be considered?

UHE is an IOException so would be problematic for a number of reasons. IAE is the right exception for bad input here.

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

PR Comment: https://git.openjdk.org/jdk/pull/15775#issuecomment-1752455199


More information about the net-dev mailing list