On Tue, 12 Oct 2021 15:43:24 GMT, Aleksei Efimov <aefi...@openjdk.org> wrote:

>> This change implements a new service provider interface for host name and 
>> address resolution, so that java.net.InetAddress API can make use of 
>> resolvers other than the platform's built-in resolver.
>> 
>> The following API classes are added to `java.net.spi` package to facilitate 
>> this:
>> - `InetAddressResolverProvider` -  abstract class defining a service, and 
>> is, essentially, a factory for `InetAddressResolver` resolvers.
>> - `InetAddressResolverProvider.Configuration ` - an interface describing the 
>> platform's built-in configuration for resolution operations that could be 
>> used to bootstrap a resolver construction, or to implement partial 
>> delegation of lookup operations.
>> - `InetAddressResolver` - an interface that defines methods for the 
>> fundamental forward and reverse lookup operations.
>> - `InetAddressResolver.LookupPolicy` - a class whose instances describe the 
>> characteristics of one forward lookup operation.  
>> 
>> More details in [JEP-418](https://openjdk.java.net/jeps/418).
>> 
>> Testing: new and existing `tier1:tier3` tests
>
> Aleksei Efimov has updated the pull request incrementally with two additional 
> commits since the last revision:
> 
>  - Add @since tags to new API classes
>  - Add checks and test for empty stream resolver results

Refactor remove Configuration and simplify interface:

In the InetAddressResolver a Configuration abstraction is defined, and this is 
supplied to
a get method of the InetAddressResolverProvider.

The objective is to “inject” some platform configuration into an 
InetAddressResolver. This
consistents of two pieces of platform configuration detail, a builtin resolver 
reference and the hostname.
Why not provide them as parameters to the provider get method and dispense with 
the Configuration
abstraction? Thus simplifying the interface. The hostname is being supplied by 
the getLocalHostName
of an InetAddressImpl. This is essentially a wrapper to the library call 
gethostname. This
could be provided as a static method in InetAddressImpl, called once during 
loadResolver to 
provide the hostname parameter String. The hostname is a static piece of system 
configuration, which
requires a system restart if it were to be changed - so need to provide a 
lambda.

So Suggestion is refector remove Configuration to simplify the interface and 
provide the
BULITIN_RESOLVER and hostname as parameters to the 
InetAddressResolverProvider::get method

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

PR: https://git.openjdk.java.net/jdk/pull/5822

Reply via email to