From 03fe0954e42abf00746b8efa4c79ee74cf514427 Mon Sep 17 00:00:00 2001
From: ludovicp <ludovicp@localhost>
Date: Thu, 27 May 2010 15:10:50 +0000
Subject: [PATCH] Fix an issue with connection timeouts in CLI. The timeout is now configurable on CLI with the --connectTimeout option (expressed in milliseconds), the default is 30 000 milliseconds. This solves Issue 4196.

---
 opends/src/server/org/opends/server/util/cli/ConsoleApplication.java |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/opends/src/server/org/opends/server/util/cli/ConsoleApplication.java b/opends/src/server/org/opends/server/util/cli/ConsoleApplication.java
index 8971d24..9042e3f 100644
--- a/opends/src/server/org/opends/server/util/cli/ConsoleApplication.java
+++ b/opends/src/server/org/opends/server/util/cli/ConsoleApplication.java
@@ -816,13 +816,14 @@
    * @param useStartTLS whether to use StartTLS or not.
    * @param bindDn the bind dn to be used.
    * @param pwd the password.
+   * @param connectTimeout the timeout in milliseconds to connect to the server.
    * @param trustManager the trust manager.
    * @return an InitialLdapContext connected.
    * @throws NamingException if there was an error establishing the connection.
    */
   protected InitialLdapContext createAdministrativeContext(String host,
       int port, boolean useSSL, boolean useStartTLS, String bindDn, String pwd,
-      ApplicationTrustManager trustManager)
+      int connectTimeout, ApplicationTrustManager trustManager)
   throws NamingException
   {
     InitialLdapContext ctx;
@@ -830,18 +831,18 @@
     if (useSSL)
     {
       ctx = Utils.createLdapsContext(ldapUrl, bindDn, pwd,
-          Utils.getDefaultLDAPTimeout(), null, trustManager);
+          connectTimeout, null, trustManager);
     }
     else if (useStartTLS)
     {
       ctx = Utils.createStartTLSContext(ldapUrl, bindDn, pwd,
-          Utils.getDefaultLDAPTimeout(), null, trustManager,
+          connectTimeout, null, trustManager,
           null);
     }
     else
     {
       ctx = Utils.createLdapContext(ldapUrl, bindDn, pwd,
-          Utils.getDefaultLDAPTimeout(), null);
+          connectTimeout, null);
     }
     if (!ConnectionUtils.connectedAsAdministrativeUser(ctx))
     {
@@ -901,7 +902,7 @@
         try
         {
           ctx = ConnectionUtils.createLdapsContext(ldapsUrl, bindDN,
-              bindPassword, ConnectionUtils.getDefaultLDAPTimeout(), null,
+              bindPassword, ci.getConnectTimeout(), null,
               trustManager, keyManager);
           ctx.reconnect(null);
           break;

--
Gitblit v1.10.0