From 53c232421f375fb7aec505cd3f152511aed47167 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Thu, 22 Oct 2009 13:31:32 +0000
Subject: [PATCH] Control Panel fix for issue 4302 (Unexpected errors using single JNDI connection with SSL and multiple threads.)
---
opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java | 115 +++++++++++++++++++++++++++++++--------------------------
1 files changed, 62 insertions(+), 53 deletions(-)
diff --git a/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java b/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java
index af2c227..c1cb3c8 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java
@@ -605,70 +605,48 @@
{
reader = createNewConfigFromDirContextReader();
((ConfigFromDirContext)reader).readConfiguration(ctx);
- if (reader.getExceptions().size() > 0)
+
+ boolean connectionWorks = checkConnections(ctx, userDataCtx);
+ if (!connectionWorks)
{
- // Check the connection
- boolean connectionWorks = false;
- int nMaxErrors = 5;
- for (int i=0; i< nMaxErrors && !connectionWorks; i++)
+ if (isLocal)
{
- try
- {
- Utilities.pingDirContext(ctx);
- connectionWorks = true;
- }
- catch (NamingException ne)
- {
- try
- {
- Thread.sleep(400);
- }
- catch (Throwable t)
- {
- }
- }
+ // Try with off-line info
+ reader = createNewConfigFromFileReader();
+ ((ConfigFromFile)reader).readConfiguration();
}
- if (!connectionWorks)
+ else
{
- if (isLocal)
- {
- // Try with offline info
- reader = createNewConfigFromFileReader();
- ((ConfigFromFile)reader).readConfiguration();
- }
- else
- {
- desc.setStatus(
- ServerDescriptor.ServerStatus.NOT_CONNECTED_TO_REMOTE);
- reader = null;
- }
+ desc.setStatus(
+ ServerDescriptor.ServerStatus.NOT_CONNECTED_TO_REMOTE);
+ reader = null;
+ }
+ try
+ {
+ ctx.close();
+ }
+ catch (Throwable t)
+ {
+ }
+ this.ctx = null;
+ if (connectionPool.isConnectionRegistered(userDataCtx))
+ {
try
{
- ctx.close();
+ connectionPool.unregisterConnection(userDataCtx);
}
catch (Throwable t)
{
}
- this.ctx = null;
- if (connectionPool.isConnectionRegistered(userDataCtx))
- {
- try
- {
- connectionPool.unregisterConnection(userDataCtx);
- }
- catch (Throwable t)
- {
- }
- }
- try
- {
- userDataCtx.close();
- }
- catch (Throwable t)
- {
- }
- userDataCtx = null;
}
+ try
+ {
+ userDataCtx.close();
+ }
+ catch (Throwable t)
+ {
+ }
+ userDataCtx = null;
}
}
}
@@ -1341,4 +1319,35 @@
}
return isRunningOnServer;
}
+
+ private boolean checkConnections(InitialLdapContext ctx,
+ InitialLdapContext userCtx)
+ {
+ // Check the connection
+ boolean connectionWorks = false;
+ int nMaxErrors = 5;
+ for (int i=0; i< nMaxErrors && !connectionWorks; i++)
+ {
+ try
+ {
+ Utilities.pingDirContext(ctx);
+ if (userCtx != null)
+ {
+ Utilities.pingDirContext(userCtx);
+ }
+ connectionWorks = true;
+ }
+ catch (NamingException ne)
+ {
+ try
+ {
+ Thread.sleep(400);
+ }
+ catch (Throwable t)
+ {
+ }
+ }
+ }
+ return connectionWorks;
+ }
}
--
Gitblit v1.10.0