coherence-community / oracle-bedrock

Oracle Bedrock
Other
55 stars 31 forks source link

Refactor Platform/Build network address selection #223

Closed brianoliver closed 9 years ago

brianoliver commented 9 years ago

With the proliferation of IP addresses now available on hosts, those being a combination of physical network adapters (ethernet, wifi, bluetooth) together with virtual network adapters (loopback, virtual machine bridges), the ability for the Java InetAddress.getLocalHost() method to return a routable InetAddress and/or a HostName that can be resolved is increasingly unlikely and unreliable. This is especially apparent when switching between different types of networks (eg: virtual private networks, office networks, home networks and networks without connectivity eg: planes!).

Unfortunately we use InetAddress.getLocalHost() to acquire host information when implementing methods like LocalPlatform.getInstance().getHostName() and Platform.getPublicAddress(). Developers who then use said methods may unfortunately be making their applications less tolerant to network changes, especially on platforms that cache network address for a long period of time (like Windows).

Windows is not the only problematic operating system. Linux is known to return different host IP address when requesting the localhost and OS X (Yosemite) recently introduced a new local network adapters (for hand-off) that appears as a valid public network adapter, but is unusable for connecting over.

Consequently we need to make some structural changes to how Platforms / Builders choose and use IP Addresses. To this end and to protect developers running into similar problems, we will implement the following changes.

  1. Introduce a Platform.getAddress() method that will return a feasible site-local InetAddress that may be used for interconnections between Platforms. This should only be used when absolutely necessary.

  2. Remove a Platform.getPublicInetAddress() and Platform.getPrivateInetAddress() as neither of these things are required.

  3. Remove LocalPlatform.getHostName() as this is inherently defective (due to the above reasons and that it may require an available DNS to operate). Should a string representation of a mechanism (an IP address) to connect to a Platform be required, calling Platform.getAddress().getHostAddress() should be used. If the hostname is really required, Platform.getAddress().getHostName() should be used (though it may fail if the host name is unknown).

  4. Introduce the ability to specify the "oracletools.platform.address" system-property so that Platform.getAddress() can be overridden in cases where it can't be determined, or determines the incorrect address.

brianoliver commented 9 years ago

@brianoliver said: This is a public-API breaking change.

Uses of Platform.getPublicInetAddress() and Platform.getPrivateInetAddress() should be replaced with calls to Platform.getAddress()

Uses of LocalPlatform.getHostName() should be replaced with Platform.getAddress().getHostName() or .getHostAddress() (if you want to avoid reverse DNS lookups).

brianoliver commented 8 years ago

This issue was imported from JIRA ORACLETOOLS-223

brianoliver commented 9 years ago

Reported by @brianoliver

brianoliver commented 9 years ago

Marked as fixed by @brianoliver on Monday, January 12th 2015, 1:43:25 pm