JDK 8 RFR 8010371: getaddrinfo can fail with EAI_SYSTEM/EAGAIN, causes UnknownHostException to be thrown
Brian Burkhalter
brian.burkhalter at oracle.com
Wed Oct 9 18:16:16 UTC 2013
On Oct 8, 2013, at 2:43 AM, Alan Bateman wrote:
>> Thanks for the previous comments. My feeling at this point is to do one of two things:
>>
>> A) defer to something after JDK 8, or
>> B) on EAI_AGAIN do not retry but set the cause of the UAE to "new SomeException(gai_strerror(error))" where SomeException could be for example Exception, RuntimeException, or IOException.
>>
>> Comments?
>>
> Throwing UHE with a useful message or cause would be best, so option B. However, I don't think it is critical for jdk8 as it's not a new issue (at least I think UHE has always been thrown with just the hostname, never the reason if it is known). So if there isn't time to be confident with the patch then it should be okay to move this out to 9.
I have created a simple implementation for option B:
http://cr.openjdk.java.net/~bpb/8010371/webrev.3/
I should note that the Unix Inet6 implementation was already using the call ThrowUnknownHostExceptionWithGaiError() to generate the UHE so in this case the message should already have been useful. This call formats the UHE message such as would:
sprintf(error_message, "%s: %s", hostname, gai_strerror(error))
I changed the Unix Inet4 implementation to do this as well instead of calling JNU_ThrowByName().
For Windows I added a similar NET_ ThrowUnknownHostExceptionWithGaiError and modified Inet{4,6} to mimic the Unix case. Note that the Windows code has not yet been compiled pending comments.
Thanks,
Brian
More information about the core-libs-dev
mailing list