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/ads/org/opends/admin/ads/util/ServerLoader.java |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/opends/src/ads/org/opends/admin/ads/util/ServerLoader.java b/opends/src/ads/org/opends/admin/ads/util/ServerLoader.java
index 7e108d3..d8aa18f 100644
--- a/opends/src/ads/org/opends/admin/ads/util/ServerLoader.java
+++ b/opends/src/ads/org/opends/admin/ads/util/ServerLoader.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2008 Sun Microsystems, Inc.
+ *      Copyright 2008-2010 Sun Microsystems, Inc.
  */
 
 package org.opends.admin.ads.util;
@@ -60,6 +60,7 @@
   private TopologyCacheException lastException;
   private ServerDescriptor serverDescriptor;
   private ApplicationTrustManager trustManager;
+  private int timeout;
   private String dn;
   private String pwd;
   private LinkedHashSet<PreferredConnection> preferredLDAPURLs;
@@ -76,6 +77,8 @@
    * @param pwd the password that we must use to bind to the server.
    * @param trustManager the ApplicationTrustManager to be used when we try
    * to connect to the server.
+   * @param timeout the timeout to establish the connection in milliseconds.
+   * Use {@code 0} to express no timeout.
    * @param preferredLDAPURLs the list of preferred LDAP URLs that we want
    * to use to connect to the server.  They will be used only if they correspond
    * to the URLs that we found in the the server properties.
@@ -84,6 +87,7 @@
    */
   public ServerLoader(Map<ServerProperty,Object> serverProperties,
       String dn, String pwd, ApplicationTrustManager trustManager,
+      int timeout,
       LinkedHashSet<PreferredConnection> preferredLDAPURLs,
       TopologyCacheFilter filter)
   {
@@ -91,6 +95,7 @@
     this.dn = dn;
     this.pwd = pwd;
     this.trustManager = trustManager;
+    this.timeout = timeout;
     this.preferredLDAPURLs =
       new LinkedHashSet<PreferredConnection>(preferredLDAPURLs);
     this.filter = filter;
@@ -276,17 +281,17 @@
         {
         case LDAPS:
           ctx = ConnectionUtils.createLdapsContext(lastLdapUrl, dn, pwd,
-              ConnectionUtils.getDefaultLDAPTimeout(), null, trustManager,
+              timeout, null, trustManager,
               null);
           break;
         case START_TLS:
           ctx = ConnectionUtils.createStartTLSContext(lastLdapUrl, dn, pwd,
-              ConnectionUtils.getDefaultLDAPTimeout(), null, trustManager,
+              timeout, null, trustManager,
               null, null);
           break;
         default:
           ctx = ConnectionUtils.createLdapContext(lastLdapUrl, dn, pwd,
-              ConnectionUtils.getDefaultLDAPTimeout(), null);
+              timeout, null);
         }
       }
     }

--
Gitblit v1.10.0