Author: tolusha
Date: 2010-08-19 10:20:08 -0400 (Thu, 19 Aug 2010)
New Revision: 2951
Modified:
core/trunk/exo.core.component.ldap/src/main/java/org/exoplatform/services/ldap/impl/LDAPServiceImpl.java
Log:
EXOJCR-909: add private method closeContext()
Modified:
core/trunk/exo.core.component.ldap/src/main/java/org/exoplatform/services/ldap/impl/LDAPServiceImpl.java
===================================================================
---
core/trunk/exo.core.component.ldap/src/main/java/org/exoplatform/services/ldap/impl/LDAPServiceImpl.java 2010-08-19
13:29:14 UTC (rev 2950)
+++
core/trunk/exo.core.component.ldap/src/main/java/org/exoplatform/services/ldap/impl/LDAPServiceImpl.java 2010-08-19
14:20:08 UTC (rev 2951)
@@ -132,15 +132,7 @@
{
// Just close since we are not pooling anything by self.
// Override this method if need other behavior.
- try
- {
- if (ctx != null)
- ctx.close();
- }
- catch (NamingException e)
- {
- LOG.warn("Exception occur when try close LDAP context. ", e);
- }
+ closeContext(ctx);
}
/**
@@ -178,17 +170,7 @@
}
finally
{
- try
- {
- if (ctx != null)
- {
- ctx.close();
- }
- }
- catch (NamingException ne)
- {
- LOG.debug("Can't close LDAP context", ne);
- }
+ closeContext(ctx);
}
}
@@ -356,4 +338,25 @@
return DEFAULT_SERVER;
}
+ /**
+ * Closes LDAP context and shows warning if exception occurred.
+ *
+ * @param ctx
+ * LDAP context
+ */
+ private void closeContext(Context ctx)
+ {
+ try
+ {
+ if (ctx != null)
+ {
+ ctx.close();
+ }
+ }
+ catch (NamingException e)
+ {
+ LOG.warn("Exception occurred when tried to close context", e);
+ }
+ }
+
}