On 10/10/2013 21:24, Brian Burkhalter wrote:On 10/10/2013 21:24, Brian Burkhalter wrote:
:
Assuming that the general idea is correct, there are a few possible 
alternatives for a final version for Windows. I am not concerned in this 
discussion about picky details including naming which can be fine tuned at the 
end.

1) In net_util_mh.c/NET_ThrowUnknownHostExceptionWithGaiError replace 
gai_strerror() with FormatMessage().

2) In Inet4AddressImpl.c and Inet6AddressImpl.c replace 
NET_ThrowUnknownHostExceptionWithGaiError with NET_ThrowByNameWithLastError 
(see net_md_util.c).

3) In net_md_util.c change (line 97 in 
http://cr.openjdk.java.net/~bpb/8010371/webrev.3/ version)

     { WSATRY_AGAIN,             0,      "Nonauthoritative host not found" },

to

     { WSATRY_AGAIN,             "UnknownHostException",      "Nonauthoritative host 
not found" },

and in Inet4AddressImpl.c and Inet6AddressImpl.c replace 
NET_ThrowUnknownHostExceptionWithGaiError with NET_ThrowNew().

4) In NET_ThrowUnknownHostExceptionWithGaiError instead of using gai_strerror() use the 
hard-coded error message "Nonauthoritative host not found".

The pros and/or cons for each, respectively, are

1) Most closely matches the Unix version and avoids hard-coded messages.

2) Simple and obviates the need for 
NET_ThrowUnknownHostExceptionWithGaiError(), but the exception message has a 
different format from the Unix version and contains the error code instead of 
an error string.

3) Simple and obviates the need for 
NET_ThrowUnknownHostExceptionWithGaiError(), but the exception message format 
is slightly different from the Unix version and the change could have the 
undesirable (and unpredictable) side effect of an UnknownHostException being 
thrown somewhere else where a SocketException used to be thrown.

4) Simplest option but has distasteful hard-coding (as do option 3 indirectly 
and NET_ThrowNew() for that matter).

If the "con" of option 2 is acceptable then I think that would be the best way 
to go, otherwise option 1.

Option #2 seems reasonable, the exception messages for similar network conditions are rarely the same on Windows and Unix anyway. However I think it's important to have verified it with one or two errors to be confident that the errors translate as expected.

One other thing to add is that winsock_errors dates from early versions of Windows whether there wasn't a means to translate Windows Sockets errors. We should look at eliminating it (not for JDK 8 of course, it's too late) so that all errors are handle translated consistently.

-Alan

Reply via email to