From 1ba9c4316ed7e368f8d0c32e71a6f2fde5669d77 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.
---
opendj-sdk/opends/src/ads/org/opends/admin/ads/ADSContextHelper.java | 35 +++++++++++++++++++++++++++++++----
1 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/opendj-sdk/opends/src/ads/org/opends/admin/ads/ADSContextHelper.java b/opendj-sdk/opends/src/ads/org/opends/admin/ads/ADSContextHelper.java
index 0caafed..fe9fcaa 100644
--- a/opendj-sdk/opends/src/ads/org/opends/admin/ads/ADSContextHelper.java
+++ b/opendj-sdk/opends/src/ads/org/opends/admin/ads/ADSContextHelper.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2007-2009 Sun Microsystems, Inc.
+ * Copyright 2007-2010 Sun Microsystems, Inc.
*/
package org.opends.admin.ads;
@@ -232,10 +232,11 @@
/* search for public-key certificate entry in ADS DIT */
final String attrIDs[] = { "ds-cfg-key-id" };
+ NamingEnumeration<SearchResult> results = null;
try
{
- final NamingEnumeration<SearchResult> results = ctx.search(
- ADSContext.getInstanceKeysContainerDN(), keyAttrs, attrIDs);
+ results = ctx.search(ADSContext.getInstanceKeysContainerDN(), keyAttrs,
+ attrIDs);
if (results.hasMore()) {
final Attribute keyIdAttr =
results.next().getAttributes().get(attrIDs[0]);
@@ -287,6 +288,10 @@
throw new ADSContextException(
ADSContextException.ErrorType.ERROR_UNEXPECTED, cme);
}
+ finally
+ {
+ handleCloseNamingEnumeration(results);
+ }
}
@@ -324,9 +329,10 @@
/* search for public-key certificate entry in ADS DIT */
final String attrIDs[] = { "ds-cfg-key-id" };
+ NamingEnumeration<SearchResult> results = null;
try
{
- final NamingEnumeration<SearchResult> results = ctx.search(
+ results = ctx.search(
ADSContext.getInstanceKeysContainerDN(), keyAttrs, attrIDs);
if (results.hasMore()) {
SearchResult res = results.next();
@@ -341,6 +347,10 @@
throw new ADSContextException(
ADSContextException.ErrorType.ERROR_UNEXPECTED, ne);
}
+ finally
+ {
+ handleCloseNamingEnumeration(results);
+ }
}
/**
@@ -364,4 +374,21 @@
{
return ConfigConstants.ATTR_CRYPTO_KEY_COMPROMISED_TIME;
}
+
+ private void handleCloseNamingEnumeration(NamingEnumeration<?> ne)
+ throws ADSContextException
+ {
+ if (ne != null)
+ {
+ try
+ {
+ ne.close();
+ }
+ catch (NamingException ex)
+ {
+ throw new ADSContextException(
+ ADSContextException.ErrorType.ERROR_UNEXPECTED, ex);
+ }
+ }
+ }
}
--
Gitblit v1.10.0