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/ConnectionUtils.java |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/opends/src/ads/org/opends/admin/ads/util/ConnectionUtils.java b/opends/src/ads/org/opends/admin/ads/util/ConnectionUtils.java
index 1290f9b..7dfe426 100644
--- a/opends/src/ads/org/opends/admin/ads/util/ConnectionUtils.java
+++ b/opends/src/ads/org/opends/admin/ads/util/ConnectionUtils.java
@@ -236,7 +236,8 @@
    * Clones the provided InitialLdapContext and returns a connection using
    * the same parameters.
    * @param ctx hte connection to be cloned.
-   * @param timeout the timeout to establish the connection.
+   * @param timeout the timeout to establish the connection in milliseconds.
+   * Use {@code 0} to express no timeout.
    * @param trustManager the trust manager to be used to connect.
    * @param keyManager the key manager to be used to connect.
    * @return the new InitialLdapContext connected to the server.
@@ -575,11 +576,13 @@
    * @param ldapUrl the ldap URL of the server.
    * @param dn the dn to be used.
    * @param pwd the password to be used.
+   * @param timeout the timeout to establish the connection in milliseconds.
+   * Use {@code 0} to express no timeout.
    * @return <CODE>true</CODE> if we can connect and read the configuration and
    * <CODE>false</CODE> otherwise.
    */
   public static boolean canConnectAsAdministrativeUser(String ldapUrl,
-      String dn, String pwd)
+      String dn, String pwd, int timeout)
   {
     boolean canConnectAsAdministrativeUser = false;
     try
@@ -587,12 +590,12 @@
       InitialLdapContext ctx;
       if (ldapUrl.toLowerCase().startsWith("ldap:"))
       {
-        ctx = createLdapContext(ldapUrl, dn, pwd, getDefaultLDAPTimeout(),
+        ctx = createLdapContext(ldapUrl, dn, pwd, timeout,
             null);
       }
       else
       {
-        ctx = createLdapsContext(ldapUrl, dn, pwd, getDefaultLDAPTimeout(),
+        ctx = createLdapsContext(ldapUrl, dn, pwd, timeout,
             null, null, null);
       }
 
@@ -646,8 +649,8 @@
    * @param t the Thread to be used to create the InitialLdapContext.
    * @param pair an Object[] array that contains the InitialLdapContext and the
    * Throwable if any occurred.
-   * @param timeout the timeout.  If we do not get to create the connection
-   * before the timeout a CommunicationException will be thrown.
+   * @param timeout the timeout in milliseconds.  If we do not get to create the
+   * connection before the timeout a CommunicationException will be thrown.
    * @return the created InitialLdapContext
    * @throws NamingException if something goes wrong during the creation.
    */

--
Gitblit v1.10.0