mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

jvergara
13.41.2009 37f30b48b3b901ec4d41af838a13b32562c169e2
Fix for issue 4399 (setup cant test free port correctly because it binds it to wrong address)

Change the code in SetupUtils to use (as described in the API):
"a socket address where the IP address is the wildcard address and the port number a specified value." instead of using the hardcoded address "localhost".
1 files modified
15 ■■■■ changed files
opendj-sdk/opends/src/server/org/opends/server/util/SetupUtils.java 15 ●●●● patch | view | raw | blame | history
opendj-sdk/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);
  }
  /**