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

Valery Kharseko
14 hours ago 4c7057e45ba8a2f3bc1f0b02b3edf14886fd1956
opendj-server-legacy/src/main/java/org/opends/server/tools/tasks/TaskTool.java
@@ -13,6 +13,7 @@
 *
 * Copyright 2007-2010 Sun Microsystems, Inc.
 * Portions Copyright 2012-2016 ForgeRock AS.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.opends.server.tools.tasks;
@@ -320,8 +321,7 @@
      }
      return 0;
    } catch (LDAPConnectionException e) {
      if (isWrongPortException(e,
          Integer.valueOf(argParser.getArguments().getPort())))
      if (isWrongPortException(e, getPortNumber()))
      {
        printWrappedText(err, ERR_TASK_LDAP_FAILED_TO_CONNECT_WRONG_PORT.get(
            argParser.getArguments().getHostName(), argParser.getArguments().getPort()));
@@ -362,6 +362,23 @@
  }
  /**
   * Returns the port this tool tried to connect to, or {@code -1} if the port argument does not
   * hold a number, in which case the connection failure cannot be a wrong port one.
   * @return the port this tool tried to connect to.
   */
  private int getPortNumber()
  {
    try
    {
      return Integer.parseInt(argParser.getArguments().getPort());
    }
    catch (NumberFormatException e)
    {
      return -1;
    }
  }
  /**
   * Returns {@code true} if the provided exception was caused by trying to
   * connect to the wrong port and {@code false} otherwise.
   * @param t the exception to be analyzed.