8022445: fix RMISocketFactory example to avoid using localhost
authorsmarks
Thu, 22 Aug 2013 15:54:50 -0700
changeset 19580 8ef7bdc1bb5a
parent 19579 ed6afb248908
child 19581 f860aff6ed05
8022445: fix RMISocketFactory example to avoid using localhost Reviewed-by: chegar, alanb
jdk/src/share/classes/java/rmi/server/RMISocketFactory.java
--- a/jdk/src/share/classes/java/rmi/server/RMISocketFactory.java	Tue Aug 20 14:13:59 2013 +0200
+++ b/jdk/src/share/classes/java/rmi/server/RMISocketFactory.java	Thu Aug 22 15:54:50 2013 -0700
@@ -50,13 +50,13 @@
  * @implNote
  * <p>You can use the {@code RMISocketFactory} class to create a server socket that
  * is bound to a specific address, restricting the origin of requests. For example,
- * the following code implements a socket factory that binds server sockets to the
+ * the following code implements a socket factory that binds server sockets to an IPv4
  * loopback address. This restricts RMI to processing requests only from the local host.
  *
  * <pre>{@code
  *     class LoopbackSocketFactory extends RMISocketFactory {
  *         public ServerSocket createServerSocket(int port) throws IOException {
- *             return new ServerSocket(port, 5, InetAddress.getLoopbackAddress());
+ *             return new ServerSocket(port, 5, InetAddress.getByName("127.0.0.1"));
  *         }
  *
  *         public Socket createSocket(String host, int port) throws IOException {
@@ -72,8 +72,8 @@
  * }</pre>
  *
  * Set the {@code java.rmi.server.hostname} system property
- * to a host name (typically {@code localhost}) that resolves to the loopback
- * interface to ensure that the generated stubs use the right network interface.
+ * to {@code 127.0.0.1} to ensure that the generated stubs connect to the right
+ * network interface.
  *
  * @author  Ann Wollrath
  * @author  Peter Jones