improving java.net.UnknownHostException

Daniel Fuchs daniel.fuchs at oracle.com
Fri Oct 29 15:00:43 UTC 2021


Hi Richard,

Information about hosts that are embedded in exceptions
are often limited and constrained for security reason.
That said, possibly some more details could be included in
some circumstances, for instance, if allowed by the
jdk.includeInExceptions property.

The platform built-in resolver that performs name-to-address
resolution delegates to `getaddrinfo`. AFAICS `getaddrinfo` doesn't
seem to provide this level of granularity in the error codes
that it might return - though maybe distinguishing between
some of the errors it returns could be envisaged.

JEP 418 (https://openjdk.java.net/jeps/418) which
is in the proposed-to-target state for 18 defines a service-provider
interface (SPI) for host name and address resolution, so that 
java.net.InetAddress can make use of resolvers other than the
platform's built-in resolver.

Such resolvers might be able to provide more details as to
what caused UnknownHostException to be thrown.

best regards,

-- daniel



On 29/10/2021 14:44, Richard Gibson wrote:
> The OCI DNS team are fielding an increasing amount of usage by customers 
> relying upon Java, and the lack of detail associated with 
> java.net.UnknownHostException for differentiating e.g. timeout vs. 
> NXDOMAIN vs. NODATA vs. SERVFAIL vs. REFUSED has cost a great deal of 
> time in investigating issues. Does anyone on this list know how to get 
> the ball rolling on improving things?



More information about the net-dev mailing list