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/guitools/org/opends/guitools/controlpanel/browser/LDAPConnectionPool.java |   26 ++++++++++++++++++++++++--
 1 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/opends/src/guitools/org/opends/guitools/controlpanel/browser/LDAPConnectionPool.java b/opends/src/guitools/org/opends/guitools/controlpanel/browser/LDAPConnectionPool.java
index 70eaa3f..b6fba3a 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/browser/LDAPConnectionPool.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/browser/LDAPConnectionPool.java
@@ -80,6 +80,7 @@
 
   private Control[] requestControls = new Control[] {};
   private ApplicationTrustManager trustManager;
+  private int connectTimeout = ConnectionUtils.getDefaultLDAPTimeout();
 
   /**
    * Returns <CODE>true</CODE> if the connection passed is registered in the
@@ -514,13 +515,13 @@
     if (isSecureLDAPUrl(ldapUrl))
     {
       ctx = ConnectionUtils.createLdapsContext(ldapUrl.toString(), ar.dn,
-          ar.password, ConnectionUtils.getDefaultLDAPTimeout(), null,
+          ar.password, getConnectTimeout(), null,
           getTrustManager() , getKeyManager());
     }
     else
     {
       ctx = ConnectionUtils.createLdapContext(ldapUrl.toString(), ar.dn,
-          ar.password, ConnectionUtils.getDefaultLDAPTimeout(), null);
+          ar.password, getConnectTimeout(), null);
     }
     return ctx;
   }
@@ -546,6 +547,27 @@
     return trustManager;
   }
 
+  /**
+   * Returns the timeout to establish the connection in milliseconds.
+   * @return the timeout to establish the connection in milliseconds.
+   */
+  public int getConnectTimeout()
+  {
+    return connectTimeout;
+  }
+
+  /**
+   * Sets the timeout to establish the connection in milliseconds.
+   * Use {@code 0} to express no timeout.
+   * @param connectTimeout the timeout to establish the connection in
+   * milliseconds.
+   * Use {@code 0} to express no timeout.
+   */
+  public void setConnectTimeout(int connectTimeout)
+  {
+    this.connectTimeout = connectTimeout;
+  }
+
   private KeyManager getKeyManager()
   {
 //  TODO: we should get it from ControlPanelInfo

--
Gitblit v1.10.0