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/task/DeleteEntryTask.java |   21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/opends/src/guitools/org/opends/guitools/controlpanel/task/DeleteEntryTask.java b/opends/src/guitools/org/opends/guitools/controlpanel/task/DeleteEntryTask.java
index 6d4ac1f..d3541b8 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/task/DeleteEntryTask.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/task/DeleteEntryTask.java
@@ -367,17 +367,24 @@
         ctx.search(Utilities.getJNDIName(dnToRemove.toString()), filter, ctls);
 
       DN entryDNFound = dnToRemove;
-      while (entryDNs.hasMore())
+      try
       {
-        SearchResult sr = entryDNs.next();
-        if (!sr.getName().equals(""))
+        while (entryDNs.hasMore())
         {
-          CustomSearchResult res =
-            new CustomSearchResult(sr, dnToRemove.toString());
-          entryDNFound = DN.decode(res.getDN());
-          deleteSubtreeRecursively(ctx, entryDNFound, null, toNotify);
+          SearchResult sr = entryDNs.next();
+          if (!sr.getName().equals(""))
+          {
+            CustomSearchResult res =
+              new CustomSearchResult(sr, dnToRemove.toString());
+            entryDNFound = DN.decode(res.getDN());
+            deleteSubtreeRecursively(ctx, entryDNFound, null, toNotify);
+          }
         }
       }
+      finally
+      {
+        entryDNs.close();
+      }
 
     } catch (NameNotFoundException nnfe) {
       // The entry is not there: it has been removed

--
Gitblit v1.10.0