jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1309744 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/server/Server.java
Date Thu, 05 Apr 2012 10:49:57 GMT
Author: jukka
Date: Thu Apr  5 10:49:56 2012
New Revision: 1309744

URL: http://svn.apache.org/viewvc?rev=1309744&view=rev
Log:
Avoid problems with 0.0.0.0 as the socket address

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/server/Server.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/server/Server.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/server/Server.java?rev=1309744&r1=1309743&r2=1309744&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/server/Server.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/server/Server.java
Thu Apr  5 10:49:56 2012
@@ -22,7 +22,9 @@ import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.ServerSocket;
 import java.net.Socket;
+import java.net.SocketAddress;
 import java.net.SocketTimeoutException;
+import java.net.UnknownHostException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -196,7 +198,22 @@ public class Server {
         if (!started.get() || stopped.get()) {
             return null;
         }
-        return (InetSocketAddress) ss.getLocalSocketAddress();
+        SocketAddress address = ss.getLocalSocketAddress();
+        if (address instanceof InetSocketAddress) {
+            InetSocketAddress isa = (InetSocketAddress) address;
+            if (isa.getAddress().isAnyLocalAddress()) {
+                try {
+                    return new InetSocketAddress(
+                            InetAddress.getByName("localhost"),
+                            ss.getLocalPort());
+                } catch (UnknownHostException e) {
+                    throw new RuntimeException(e);
+                }
+            } else {
+                return isa;
+            }
+        }
+        return null;
     }
 
     /**



Mime
View raw message