From 3749749fcfc4a3f9821fa8df2c0b93688971628e Mon Sep 17 00:00:00 2001
From: ludovicp <ludovicp@localhost>
Date: Mon, 31 May 2010 12:48:19 +0000
Subject: [PATCH] Fix for issue #4536. Close JNDI enumerations to avoid unbinding and closing underlying LDAP connection. Fixes in all CLI and control panel.

---
 opends/src/guitools/org/opends/guitools/controlpanel/util/LDAPEntryReader.java |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/opends/src/guitools/org/opends/guitools/controlpanel/util/LDAPEntryReader.java b/opends/src/guitools/org/opends/guitools/controlpanel/util/LDAPEntryReader.java
index db80d86..49837fe 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/util/LDAPEntryReader.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/util/LDAPEntryReader.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2008-2009 Sun Microsystems, Inc.
+ *      Copyright 2008-2010 Sun Microsystems, Inc.
  */
 
 package org.opends.guitools.controlpanel.util;
@@ -72,6 +72,7 @@
   public CustomSearchResult processBackgroundTask() throws Throwable
   {
     isOver = false;
+    NamingEnumeration<SearchResult> en = null;
     try
     {
       SearchControls controls = new SearchControls();
@@ -82,8 +83,7 @@
       controls.setSearchScope(SearchControls.OBJECT_SCOPE);
       final String filter = "(|(objectclass=*)(objectclass=ldapsubentry))";
 
-      NamingEnumeration<SearchResult> en =
-        ctx.search(Utilities.getJNDIName(dn), filter, controls);
+      en = ctx.search(Utilities.getJNDIName(dn), filter, controls);
 
       SearchResult sr = en.next();
 
@@ -95,6 +95,10 @@
       {
         isOver = true;
       }
+      if (en != null)
+      {
+        en.close();
+      }
     }
   }
 

--
Gitblit v1.10.0