Author: tolusha
Date: 2010-08-19 08:50:39 -0400 (Thu, 19 Aug 2010)
New Revision: 2948
Added:
core/branches/2.3.x/patch/
core/branches/2.3.x/patch/EXOJCR-909/
core/branches/2.3.x/patch/EXOJCR-909/EXOJCR-909.patch
Modified:
core/branches/2.3.x/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/branches/2.3.x/exo.core.component.ldap/src/main/java/org/exoplatform/services/ldap/impl/LDAPServiceImpl.java
===================================================================
---
core/branches/2.3.x/exo.core.component.ldap/src/main/java/org/exoplatform/services/ldap/impl/LDAPServiceImpl.java 2010-08-19
12:49:00 UTC (rev 2947)
+++
core/branches/2.3.x/exo.core.component.ldap/src/main/java/org/exoplatform/services/ldap/impl/LDAPServiceImpl.java 2010-08-19
12:50:39 UTC (rev 2948)
@@ -164,9 +164,11 @@
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)
@@ -175,6 +177,20 @@
e.printStackTrace();
return false;
}
+ finally
+ {
+ try
+ {
+ if (ctx != null)
+ {
+ ctx.close();
+ }
+ }
+ catch (NamingException ne)
+ {
+ LOG.debug("Can't close LDAP context", ne);
+ }
+ }
}
/**
Added: core/branches/2.3.x/patch/EXOJCR-909/EXOJCR-909.patch
===================================================================
--- core/branches/2.3.x/patch/EXOJCR-909/EXOJCR-909.patch (rev 0)
+++ core/branches/2.3.x/patch/EXOJCR-909/EXOJCR-909.patch 2010-08-19 12:50:39 UTC (rev
2948)
@@ -0,0 +1,40 @@
+Index:
exo.core.component.ldap/src/main/java/org/exoplatform/services/ldap/impl/LDAPServiceImpl.java
+===================================================================
+---
exo.core.component.ldap/src/main/java/org/exoplatform/services/ldap/impl/LDAPServiceImpl.java (revision
2946)
++++
exo.core.component.ldap/src/main/java/org/exoplatform/services/ldap/impl/LDAPServiceImpl.java (working
copy)
+@@ -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);
++ }
++ }
+ }
+
+ /**
Show replies by date