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

ludovicp
03.19.2010 32d694939d9deac5b4ef008855c2fe1dc97513a3
Revert commit 6559 and complete commit 6550.
There were some inconsistencies in the way the connectTimeout was applied to the tools.
The time out should only apply to the establishing of the connection not to every operation done in the connection. But due to a defect, the timeout was kept for all subsequent operations preventing some of them to complete.
The proposed changes reset the timeout of the socket to 0 (no timeout) once the connection has been established.
Default connection timeout has been reset to 30 seconds for all tools.
7 files modified
48 ■■■■ changed files
opends/src/server/org/opends/server/tools/LDAPCompare.java 4 ●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/LDAPConnection.java 23 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/LDAPDelete.java 4 ●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/LDAPModify.java 5 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/LDAPPasswordModify.java 4 ●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/LDAPSearch.java 5 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/PromptTrustManager.java 3 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/LDAPCompare.java
@@ -25,6 +25,7 @@
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 */
package org.opends.server.tools;
import org.opends.admin.ads.util.ConnectionUtils;
import org.opends.messages.Message;
import java.io.BufferedReader;
@@ -596,10 +597,11 @@
      version.setPropertyName(OPTION_LONG_PROTOCOL_VERSION);
      argParser.addArgument(version);
      int defaultTimeout = ConnectionUtils.getDefaultLDAPTimeout();
      connectTimeout = new IntegerArgument(OPTION_LONG_CONNECT_TIMEOUT,
          null, OPTION_LONG_CONNECT_TIMEOUT,
          false, false, true, INFO_TIMEOUT_PLACEHOLDER.get(),
          0, null,
          defaultTimeout, null,
          true, 0, false, Integer.MAX_VALUE,
          INFO_DESCRIPTION_CONNECTION_TIMEOUT.get());
      connectTimeout.setPropertyName(OPTION_LONG_CONNECT_TIMEOUT);
opends/src/server/org/opends/server/tools/LDAPConnection.java
@@ -31,6 +31,7 @@
import java.io.IOException;
import java.net.ConnectException;
import java.net.Socket;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicInteger;
@@ -82,8 +83,8 @@
  private LDAPReader ldapReader;
  private int versionNumber = 3;
  private PrintStream out;
  private PrintStream err;
  private final PrintStream out;
  private final PrintStream err;
  /**
   * Constructor for the LDAPConnection object.
@@ -509,6 +510,24 @@
      throw new LDAPConnectionException(
              Message.raw(ex.getLocalizedMessage()),ex);
    }
    finally
    {
      if (timeout > 0)
      {
        try
        {
          socket.setSoTimeout(0);
        }
        catch (SocketException e)
        {
          e.printStackTrace();
          if (debugEnabled())
          {
            TRACER.debugCaught(DebugLogLevel.ERROR, e);
          }
        }
      }
    }
  }
opends/src/server/org/opends/server/tools/LDAPDelete.java
@@ -25,6 +25,7 @@
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 */
package org.opends.server.tools;
import org.opends.admin.ads.util.ConnectionUtils;
import org.opends.messages.Message;
import java.io.BufferedReader;
@@ -539,10 +540,11 @@
      version.setPropertyName(OPTION_LONG_PROTOCOL_VERSION);
      argParser.addArgument(version);
      int defaultTimeout = ConnectionUtils.getDefaultLDAPTimeout();
      connectTimeout = new IntegerArgument(OPTION_LONG_CONNECT_TIMEOUT,
          null, OPTION_LONG_CONNECT_TIMEOUT,
          false, false, true, INFO_TIMEOUT_PLACEHOLDER.get(),
          0, null,
          defaultTimeout, null,
          true, 0, false, Integer.MAX_VALUE,
          INFO_DESCRIPTION_CONNECTION_TIMEOUT.get());
      connectTimeout.setPropertyName(OPTION_LONG_CONNECT_TIMEOUT);
opends/src/server/org/opends/server/tools/LDAPModify.java
@@ -25,7 +25,7 @@
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 */
package org.opends.server.tools;
import org.opends.admin.ads.util.ConnectionUtils;
import org.opends.messages.Message;
import java.io.FileInputStream;
@@ -902,10 +902,11 @@
      version.setPropertyName(OPTION_LONG_PROTOCOL_VERSION);
      argParser.addArgument(version);
      int defaultTimeout = ConnectionUtils.getDefaultLDAPTimeout();
      connectTimeout = new IntegerArgument(OPTION_LONG_CONNECT_TIMEOUT,
          null, OPTION_LONG_CONNECT_TIMEOUT,
          false, false, true, INFO_TIMEOUT_PLACEHOLDER.get(),
          0, null,
          defaultTimeout, null,
          true, 0, false, Integer.MAX_VALUE,
          INFO_DESCRIPTION_CONNECTION_TIMEOUT.get());
      connectTimeout.setPropertyName(OPTION_LONG_CONNECT_TIMEOUT);
opends/src/server/org/opends/server/tools/LDAPPasswordModify.java
@@ -25,6 +25,7 @@
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 */
package org.opends.server.tools;
import org.opends.admin.ads.util.ConnectionUtils;
import org.opends.messages.Message;
@@ -406,10 +407,11 @@
      controlStr.setPropertyName("control");
      argParser.addArgument(controlStr);
      int defaultTimeout = ConnectionUtils.getDefaultLDAPTimeout();
      connectTimeout = new IntegerArgument(OPTION_LONG_CONNECT_TIMEOUT,
          null, OPTION_LONG_CONNECT_TIMEOUT,
          false, false, true, INFO_TIMEOUT_PLACEHOLDER.get(),
          0, null,
          defaultTimeout, null,
          true, 0, false, Integer.MAX_VALUE,
          INFO_DESCRIPTION_CONNECTION_TIMEOUT.get());
      connectTimeout.setPropertyName(OPTION_LONG_CONNECT_TIMEOUT);
opends/src/server/org/opends/server/tools/LDAPSearch.java
@@ -25,7 +25,7 @@
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 */
package org.opends.server.tools;
import org.opends.admin.ads.util.ConnectionUtils;
import org.opends.messages.Message;
import java.io.BufferedReader;
@@ -1022,10 +1022,11 @@
      version.setPropertyName(OPTION_LONG_PROTOCOL_VERSION);
      argParser.addArgument(version);
      int defaultTimeout = ConnectionUtils.getDefaultLDAPTimeout();
      connectTimeout = new IntegerArgument(OPTION_LONG_CONNECT_TIMEOUT,
          null, OPTION_LONG_CONNECT_TIMEOUT,
          false, false, true, INFO_TIMEOUT_PLACEHOLDER.get(),
          0, null,
          defaultTimeout, null,
          true, 0, false, Integer.MAX_VALUE,
          INFO_DESCRIPTION_CONNECTION_TIMEOUT.get());
      connectTimeout.setPropertyName(OPTION_LONG_CONNECT_TIMEOUT);
opends/src/server/org/opends/server/tools/PromptTrustManager.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 */
package org.opends.server.tools;
import org.opends.messages.Message;
@@ -39,7 +39,6 @@
import javax.net.ssl.X509TrustManager;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.util.StaticUtils.*;