From a5063d331b45c3d9d7a337a611ea8caeaa91e43f Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Sun, 13 Dec 2009 21:41:20 +0000
Subject: [PATCH] Fix for issue 4399 (setup cant test free port correctly because it binds it to wrong address)

---
 opends/src/server/org/opends/server/util/SetupUtils.java |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/opends/src/server/org/opends/server/util/SetupUtils.java b/opends/src/server/org/opends/server/util/SetupUtils.java
index 7033c5d..b91ff88 100644
--- a/opends/src/server/org/opends/server/util/SetupUtils.java
+++ b/opends/src/server/org/opends/server/util/SetupUtils.java
@@ -369,7 +369,8 @@
   /**
    * Returns {@code true} if the provided port is free and we can use it,
    * {@code false} otherwise.
-   * @param hostname the host name we are analyzing.
+   * @param hostname the host name we are analyzing.  Use <CODE>null</CODE>
+   * to connect to any address.
    * @param port the port we are analyzing.
    * @return {@code true} if the provided port is free and we can use it,
    * {@code false} otherwise.
@@ -380,7 +381,15 @@
     ServerSocket serverSocket = null;
     try
     {
-      InetSocketAddress socketAddress = new InetSocketAddress(hostname, port);
+      InetSocketAddress socketAddress;
+      if (hostname != null)
+      {
+        socketAddress = new InetSocketAddress(hostname, port);
+      }
+      else
+      {
+        socketAddress = new InetSocketAddress(port);
+      }
       serverSocket = new ServerSocket();
       if (!isWindows())
       {
@@ -448,7 +457,7 @@
    */
   public static boolean canUseAsPort(int port)
   {
-    return canUseAsPort("localhost", port);
+    return canUseAsPort(null, port);
   }
 
   /**

--
Gitblit v1.10.0