From 66c1a80d263b71195a525d1c1fdd59e464a606ae Mon Sep 17 00:00:00 2001
From: ludovicp <ludovicp@localhost>
Date: Fri, 20 Aug 2010 13:39:26 +0000
Subject: [PATCH] Fix all command lines that are doing Searches with JNDI, to avoid them sending systematic Abandon requests.

---
 opends/src/ads/org/opends/admin/ads/ADSContextHelper.java |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/opends/src/ads/org/opends/admin/ads/ADSContextHelper.java b/opends/src/ads/org/opends/admin/ads/ADSContextHelper.java
index fe9fcaa..370e174 100644
--- a/opends/src/ads/org/opends/admin/ads/ADSContextHelper.java
+++ b/opends/src/ads/org/opends/admin/ads/ADSContextHelper.java
@@ -235,15 +235,17 @@
     NamingEnumeration<SearchResult> results = null;
     try
     {
-     results = ctx.search(ADSContext.getInstanceKeysContainerDN(), keyAttrs,
+      results = ctx.search(ADSContext.getInstanceKeysContainerDN(), keyAttrs,
          attrIDs);
-      if (results.hasMore()) {
+      boolean found = false;
+      while (results.hasMore()) {
         final Attribute keyIdAttr =
           results.next().getAttributes().get(attrIDs[0]);
         if (null != keyIdAttr) {
           /* attribute ds-cfg-key-id is the entry is a MUST in the schema */
           keyID = (String)keyIdAttr.get();
         }
+        found = true;
       }
       /* TODO: It is possible (but unexpected) that the caller specifies a
    ds-cfg-key-id value for which there is a certificate entry in ADS, but
@@ -251,7 +253,7 @@
    above search would not return the entry, but the below attempt to add
    an new entry with the supplied ds-cfg-key-id will fail (throw a
    NameAlreadyBoundException) */
-      else {
+      if (!found) {
         /* create key ID, if it was not supplied in serverProperties */
         if (null == keyID) {
           keyID = CryptoManagerImpl.getInstanceKeyID(
@@ -334,7 +336,7 @@
     {
       results = ctx.search(
           ADSContext.getInstanceKeysContainerDN(), keyAttrs, attrIDs);
-      if (results.hasMore()) {
+      while (results.hasMore()) {
         SearchResult res = results.next();
         ctx.destroySubcontext(res.getNameInNamespace());
       }

--
Gitblit v1.10.0