Author: sijskes
Date: Sat Oct 13 13:00:48 2012
New Revision: 1397824

URL: http://svn.apache.org/viewvc?rev=1397824&view=rev
Log:
RIVER-413 routed all non-test getLocalHost calls to LocalHostLookup

Modified:
    river/jtsk/trunk/src/com/sun/jini/config/ConfigUtil.java
    river/jtsk/trunk/src/com/sun/jini/reggie/RegistrarImpl.java
    river/jtsk/trunk/src/com/sun/jini/tool/ClassServer.java
    river/jtsk/trunk/src/net/jini/discovery/LookupDiscovery.java
    river/jtsk/trunk/src/net/jini/jeri/http/HttpServerEndpoint.java
    river/jtsk/trunk/src/net/jini/jeri/kerberos/KerberosServerEndpoint.java
    river/jtsk/trunk/src/net/jini/jeri/ssl/SslServerEndpointImpl.java
    river/jtsk/trunk/src/net/jini/jeri/tcp/TcpServerEndpoint.java
    river/jtsk/trunk/src/org/apache/river/config/LocalHostLookup.java

Modified: river/jtsk/trunk/src/com/sun/jini/config/ConfigUtil.java
URL: 
http://svn.apache.org/viewvc/river/jtsk/trunk/src/com/sun/jini/config/ConfigUtil.java?rev=1397824&r1=1397823&r2=1397824&view=diff
==============================================================================
--- river/jtsk/trunk/src/com/sun/jini/config/ConfigUtil.java (original)
+++ river/jtsk/trunk/src/com/sun/jini/config/ConfigUtil.java Sat Oct 13 
13:00:48 2012
@@ -21,6 +21,7 @@ import net.jini.core.lookup.ServiceID;
 import net.jini.id.Uuid;
 import net.jini.id.UuidFactory;
 import java.net.UnknownHostException;
+import org.apache.river.config.LocalHostLookup;
 
 /**
  * A set of static convenience methods for use in configuration files.
@@ -66,7 +67,7 @@ public class ConfigUtil {
      *         host could be found.
      */
     public static String getHostName() throws UnknownHostException {
-        return java.net.InetAddress.getLocalHost().getCanonicalHostName();
+        return LocalHostLookup.getLocalHost().getCanonicalHostName();
     }
     
     /**
@@ -76,7 +77,7 @@ public class ConfigUtil {
      *         host could be found.
      */
     public static String getHostAddress() throws UnknownHostException {
-         return java.net.InetAddress.getLocalHost().getHostAddress();
+         return LocalHostLookup.getLocalHost().getHostAddress();
     }
 
 

Modified: river/jtsk/trunk/src/com/sun/jini/reggie/RegistrarImpl.java
URL: 
http://svn.apache.org/viewvc/river/jtsk/trunk/src/com/sun/jini/reggie/RegistrarImpl.java?rev=1397824&r1=1397823&r2=1397824&view=diff
==============================================================================
--- river/jtsk/trunk/src/com/sun/jini/reggie/RegistrarImpl.java (original)
+++ river/jtsk/trunk/src/com/sun/jini/reggie/RegistrarImpl.java Sat Oct 13 
13:00:48 2012
@@ -128,6 +128,7 @@ import net.jini.security.BasicProxyPrepa
 import net.jini.security.ProxyPreparer;
 import net.jini.security.TrustVerifier;
 import net.jini.security.proxytrust.ServerProxyTrust;
+import org.apache.river.config.LocalHostLookup;
 
 /**
  * Base server-side implementation of a lookup service, subclassed by
@@ -2545,7 +2546,7 @@ class RegistrarImpl implements Registrar
         */
        public synchronized void interrupt() {
            try {
-                Socket s = 
socketFactory.createSocket(InetAddress.getLocalHost(), port);
+                Socket s = 
socketFactory.createSocket(LocalHostLookup.getLocalHost(), port);
                 s.close();
            } catch (IOException e) {
            }
@@ -4637,7 +4638,7 @@ class RegistrarImpl implements Registrar
        } catch (NoSuchEntryException e) {
            // fix for 4906732: only invoke getCanonicalHostName if needed
            unicastDiscoveryHost =
-               InetAddress.getLocalHost().getCanonicalHostName();
+               LocalHostLookup.getLocalHost().getCanonicalHostName();
        }
        try {
            unicastDiscoverySubjectChecker =

Modified: river/jtsk/trunk/src/com/sun/jini/tool/ClassServer.java
URL: 
http://svn.apache.org/viewvc/river/jtsk/trunk/src/com/sun/jini/tool/ClassServer.java?rev=1397824&r1=1397823&r2=1397824&view=diff
==============================================================================
--- river/jtsk/trunk/src/com/sun/jini/tool/ClassServer.java (original)
+++ river/jtsk/trunk/src/com/sun/jini/tool/ClassServer.java Sat Oct 13 13:00:48 
2012
@@ -48,6 +48,7 @@ import java.util.jar.JarFile;
 import java.util.jar.Manifest;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+import org.apache.river.config.LocalHostLookup;
 
 /**
  * A simple HTTP server, for serving up JAR and class files.
@@ -837,7 +838,7 @@ public class ClassServer extends Thread 
        }
        try {
            if (stop) {
-               Socket sock = new Socket(InetAddress.getLocalHost(), port);
+               Socket sock = new Socket(LocalHostLookup.getLocalHost(), port);
                try {
                    DataOutputStream out =
                        new DataOutputStream(sock.getOutputStream());

Modified: river/jtsk/trunk/src/net/jini/discovery/LookupDiscovery.java
URL: 
http://svn.apache.org/viewvc/river/jtsk/trunk/src/net/jini/discovery/LookupDiscovery.java?rev=1397824&r1=1397823&r2=1397824&view=diff
==============================================================================
--- river/jtsk/trunk/src/net/jini/discovery/LookupDiscovery.java (original)
+++ river/jtsk/trunk/src/net/jini/discovery/LookupDiscovery.java Sat Oct 13 
13:00:48 2012
@@ -79,6 +79,7 @@ import net.jini.security.BasicProxyPrepa
 import net.jini.security.ProxyPreparer;
 import net.jini.security.Security;
 import net.jini.security.SecurityContext;
+import org.apache.river.config.LocalHostLookup;
 
 /**
  * This class is a helper utility class that encapsulates the functionality 
@@ -1240,7 +1241,7 @@ public class LookupDiscovery implements 
        public void interrupt() {
            interrupted = true;
            try {
-               (new Socket(InetAddress.getLocalHost(), getPort())).close();
+               (new Socket(LocalHostLookup.getLocalHost(), getPort())).close();
            } catch (IOException e) { /* ignore */ }
        }//end interrupt
 
@@ -2386,14 +2387,14 @@ public class LookupDiscovery implements 
            return ((InetAddress) Security.doPrivileged(
                new PrivilegedExceptionAction() {
                    public Object run() throws UnknownHostException {
-                       return InetAddress.getLocalHost();
+                       return LocalHostLookup.getLocalHost();
                    }
                })).getHostAddress();
        } catch (PrivilegedActionException e) {
            // Remove host information if caller does not have privileges
            // to see it.
            try {
-               InetAddress.getLocalHost();
+               LocalHostLookup.getLocalHost();
            } catch (UnknownHostException uhe) {
                throw uhe;
            }

Modified: river/jtsk/trunk/src/net/jini/jeri/http/HttpServerEndpoint.java
URL: 
http://svn.apache.org/viewvc/river/jtsk/trunk/src/net/jini/jeri/http/HttpServerEndpoint.java?rev=1397824&r1=1397823&r2=1397824&view=diff
==============================================================================
--- river/jtsk/trunk/src/net/jini/jeri/http/HttpServerEndpoint.java (original)
+++ river/jtsk/trunk/src/net/jini/jeri/http/HttpServerEndpoint.java Sat Oct 13 
13:00:48 2012
@@ -54,6 +54,7 @@ import net.jini.jeri.RequestDispatcher;
 import net.jini.jeri.ServerEndpoint;
 import net.jini.security.Security;
 import net.jini.security.SecurityContext;
+import org.apache.river.config.LocalHostLookup;
 
 /**
  * An implementation of the {@link ServerEndpoint} abstraction that
@@ -517,7 +518,7 @@ public final class HttpServerEndpoint im
                localAddr = (InetAddress) Security.doPrivileged(
                    new PrivilegedExceptionAction() {
                        public Object run() throws UnknownHostException {
-                           return InetAddress.getLocalHost();
+                           return LocalHostLookup.getLocalHost();
                        }
                    });
            } catch (PrivilegedActionException e) {
@@ -527,7 +528,7 @@ public final class HttpServerEndpoint im
                 * in the caller's security context; otherwise, throw
                 * a new UnknownHostException without the host name.
                 */
-               InetAddress.getLocalHost();
+               LocalHostLookup.getLocalHost();
                throw new UnknownHostException(
                    "access to resolve local host denied");
            }

Modified: 
river/jtsk/trunk/src/net/jini/jeri/kerberos/KerberosServerEndpoint.java
URL: 
http://svn.apache.org/viewvc/river/jtsk/trunk/src/net/jini/jeri/kerberos/KerberosServerEndpoint.java?rev=1397824&r1=1397823&r2=1397824&view=diff
==============================================================================
--- river/jtsk/trunk/src/net/jini/jeri/kerberos/KerberosServerEndpoint.java 
(original)
+++ river/jtsk/trunk/src/net/jini/jeri/kerberos/KerberosServerEndpoint.java Sat 
Oct 13 13:00:48 2012
@@ -74,6 +74,7 @@ import javax.net.ServerSocketFactory;
 import javax.security.auth.Subject;
 import javax.security.auth.kerberos.KerberosKey;
 import javax.security.auth.kerberos.KerberosPrincipal;
+import org.apache.river.config.LocalHostLookup;
 import org.ietf.jgss.GSSContext;
 import org.ietf.jgss.GSSCredential;
 import org.ietf.jgss.GSSException;
@@ -1121,7 +1122,7 @@ public final class KerberosServerEndpoin
                localAddr = (InetAddress) AccessController.doPrivileged(
                    new PrivilegedExceptionAction() {
                            public Object run() throws UnknownHostException {
-                               return InetAddress.getLocalHost();
+                               return LocalHostLookup.getLocalHost();
                            }
                        });
            } catch (PrivilegedActionException e) {
@@ -1135,7 +1136,7 @@ public final class KerberosServerEndpoin
                // Remove host information if caller does not have privileges
                // to see it.
                try {
-                   InetAddress.getLocalHost();
+                   LocalHostLookup.getLocalHost();
                } catch (UnknownHostException te) {
                    throw te;
                }

Modified: river/jtsk/trunk/src/net/jini/jeri/ssl/SslServerEndpointImpl.java
URL: 
http://svn.apache.org/viewvc/river/jtsk/trunk/src/net/jini/jeri/ssl/SslServerEndpointImpl.java?rev=1397824&r1=1397823&r2=1397824&view=diff
==============================================================================
--- river/jtsk/trunk/src/net/jini/jeri/ssl/SslServerEndpointImpl.java (original)
+++ river/jtsk/trunk/src/net/jini/jeri/ssl/SslServerEndpointImpl.java Sat Oct 
13 13:00:48 2012
@@ -81,6 +81,7 @@ import net.jini.jeri.connection.ServerCo
 import net.jini.security.AuthenticationPermission;
 import net.jini.security.Security;
 import net.jini.security.SecurityContext;
+import org.apache.river.config.LocalHostLookup;
 
 /**
  * Provides the implementation of SslServerEndpoint so that the implementation
@@ -546,7 +547,7 @@ class SslServerEndpointImpl extends Util
                    // Remove host information if caller does not have
                    // privileges to see it.
                    try {
-                       InetAddress.getLocalHost();
+                       LocalHostLookup.getLocalHost();
                    } catch (UnknownHostException te) {
                        throw te;
                    }

Modified: river/jtsk/trunk/src/net/jini/jeri/tcp/TcpServerEndpoint.java
URL: 
http://svn.apache.org/viewvc/river/jtsk/trunk/src/net/jini/jeri/tcp/TcpServerEndpoint.java?rev=1397824&r1=1397823&r2=1397824&view=diff
==============================================================================
--- river/jtsk/trunk/src/net/jini/jeri/tcp/TcpServerEndpoint.java (original)
+++ river/jtsk/trunk/src/net/jini/jeri/tcp/TcpServerEndpoint.java Sat Oct 13 
13:00:48 2012
@@ -60,6 +60,7 @@ import net.jini.jeri.connection.ServerCo
 import net.jini.jeri.connection.ServerConnectionManager;
 import net.jini.security.Security;
 import net.jini.security.SecurityContext;
+import org.apache.river.config.LocalHostLookup;
 
 /**
  * An implementation of the {@link ServerEndpoint} abstraction that
@@ -524,7 +525,7 @@ public final class TcpServerEndpoint imp
                localAddr = (InetAddress) AccessController.doPrivileged(
                    new PrivilegedExceptionAction() {
                        public Object run() throws UnknownHostException {
-                           return InetAddress.getLocalHost();
+                           return LocalHostLookup.getLocalHost();
                        }
                    });
            } catch (PrivilegedActionException e) {
@@ -534,7 +535,7 @@ public final class TcpServerEndpoint imp
                 * in the caller's security context; otherwise, throw
                 * a new UnknownHostException without the host name.
                 */
-               InetAddress.getLocalHost();
+               LocalHostLookup.getLocalHost();
                throw new UnknownHostException(
                    "access to resolve local host denied");
            }

Modified: river/jtsk/trunk/src/org/apache/river/config/LocalHostLookup.java
URL: 
http://svn.apache.org/viewvc/river/jtsk/trunk/src/org/apache/river/config/LocalHostLookup.java?rev=1397824&r1=1397823&r2=1397824&view=diff
==============================================================================
--- river/jtsk/trunk/src/org/apache/river/config/LocalHostLookup.java (original)
+++ river/jtsk/trunk/src/org/apache/river/config/LocalHostLookup.java Sat Oct 
13 13:00:48 2012
@@ -28,23 +28,29 @@ public class LocalHostLookup
 {
     private final static Logger logger = 
Logger.getLogger(LocalHostLookup.class.getName());
 
-    private static InetAddress localHost ;
-
     public static InetAddress getLocalHost() throws UnknownHostException
     {
-        if( localHost == null ) {
-            setLocalHost( InetAddress.getLocalHost() );
-        }
-        return localHost ;
+        return InetAddress.getLocalHost();
     }
 
-    private static void setLocalHost(InetAddress localHost)
-    {
-        if( localHost.isLoopbackAddress() ) {
-            logger.warning( "local host is loopback" );
-        }
-        LocalHostLookup.localHost = localHost ;
-    }
+
+//    private static InetAddress localHost ;
+//
+//    public static InetAddress getLocalHost() throws UnknownHostException
+//    {
+//        if( localHost == null ) {
+//            setLocalHost( InetAddress.getLocalHost() );
+//        }
+//        return localHost ;
+//    }
+//
+//    private static void setLocalHost(InetAddress localHost)
+//    {
+//        if( localHost.isLoopbackAddress() ) {
+//            logger.warning( "local host is loopback" );
+//        }
+//        LocalHostLookup.localHost = localHost ;
+//    }
 
     private LocalHostLookup()
     {


Reply via email to