RFR: 8227493: Return a more useful error message from lookupAllHostAddr if getaddrinfo results in EAI_SYSTEM error [v2]
Daniel Jeliński
djelinski at openjdk.org
Wed Jan 22 16:58:49 UTC 2025
On Mon, 2 Dec 2024 16:35:06 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:
>> Can I please get a review of this minor enhancement to the error text that is reported if the `getaddrinfo()` native call returns the `EAI_SYSTEM` error? This addresses https://bugs.openjdk.org/browse/JDK-8227493.
>>
>> The `java.net.InetAddress` class, in its implementation for resolving addresses for a host name, calls the `getaddrinfo()` native call on *nix platforms. If `getaddrinfo()` returns an error then we use the `gai_strerror()` native call to convert the error number into an error string that is then propagated to the application. Among other errors, the `getaddrinfo()` is specified to return the error code `EAI_SYSTEM` which as per its documentation represents
>>
>>> EAI_SYSTEM system error returned in errno
>>
>> So calling `gai_strerror()` merely returns a generic "System error" text. The real underlying error is present in the `errno` and that has more useful information.
>>
>> The commit in this PR checks the error for `EAI_SYSTEM` and if it matches then it additionally gets the error text corresponding to `errno`. So the error text that gets propagated will now be "System error: Illegal byte sequence", assuming `EILSEQ` was the underlying `errno` for the `getaddrinfo` call (my use of `EILSEQ` in this example is arbitrary and it's merely to show what the error text will look like after this change).
>>
>> Given the nature of this change no new test has been introduced. Existing tests in tier1, tier2 and tier3 continue to pass with this change.
>
> Jaikiran Pai has updated the pull request incrementally with one additional commit since the last revision:
>
> fix size computation
Marked as reviewed by djelinski (Reviewer).
-------------
PR Review: https://git.openjdk.org/jdk/pull/22484#pullrequestreview-2567780801
More information about the net-dev
mailing list