Author: tolusha
Date: 2010-08-19 08:49:00 -0400 (Thu, 19 Aug 2010)
New Revision: 2947
Modified:
core/trunk/exo.core.component.ldap/src/main/java/org/exoplatform/services/ldap/impl/LDAPServiceImpl.java
Log:
EXOJCR-909: close LDAP context in LDAPServiceImpl.authenticate() method
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
07:30:57 UTC (rev 2946)
+++
core/trunk/exo.core.component.ldap/src/main/java/org/exoplatform/services/ldap/impl/LDAPServiceImpl.java 2010-08-19
12:49:00 UTC (rev 2947)
@@ -164,17 +164,32 @@
props.put(Context.SECURITY_PRINCIPAL, userDN);
props.put(Context.SECURITY_CREDENTIALS, password);
props.put("com.sun.jndi.ldap.connect.pool", "false");
+
+ InitialContext ctx = null;
try
{
- new InitialLdapContext(props, null);
+ ctx = new InitialLdapContext(props, null);
return true;
}
catch (NamingException e)
{
- if (LOG.isDebugEnabled())
- e.printStackTrace();
+ LOG.debug("Error during initialization LDAP Context", e);
return false;
}
+ finally
+ {
+ try
+ {
+ if (ctx != null)
+ {
+ ctx.close();
+ }
+ }
+ catch (NamingException ne)
+ {
+ LOG.debug("Can't close LDAP context", ne);
+ }
+ }
}
/**