[exo-jcr-commits] exo-jcr SVN: r4903 - core/trunk/exo.core.component.ldap/src/main/java/org/exoplatform/services/ldap/impl.
do-not-reply at jboss.org
do-not-reply at jboss.org
Tue Sep 13 09:08:32 EDT 2011
Author: tolusha
Date: 2011-09-13 09:08:32 -0400 (Tue, 13 Sep 2011)
New Revision: 4903
Modified:
core/trunk/exo.core.component.ldap/src/main/java/org/exoplatform/services/ldap/impl/LDAPConnectionConfig.java
core/trunk/exo.core.component.ldap/src/main/java/org/exoplatform/services/ldap/impl/LDAPServiceImpl.java
Log:
EXOJCR-1530: Connections leaks in LDAP OrganizationService
Modified: core/trunk/exo.core.component.ldap/src/main/java/org/exoplatform/services/ldap/impl/LDAPConnectionConfig.java
===================================================================
--- core/trunk/exo.core.component.ldap/src/main/java/org/exoplatform/services/ldap/impl/LDAPConnectionConfig.java 2011-09-13 12:58:47 UTC (rev 4902)
+++ core/trunk/exo.core.component.ldap/src/main/java/org/exoplatform/services/ldap/impl/LDAPConnectionConfig.java 2011-09-13 13:08:32 UTC (rev 4903)
@@ -40,6 +40,8 @@
private int maxConnection;
+ private int timeout;
+
private String referralMode = "follow";
public String getRootDN()
@@ -72,6 +74,11 @@
this.version = v;
}
+ public void setTimeout(int timeout)
+ {
+ this.timeout = timeout;
+ }
+
public String getAuthenticationType()
{
return authenticationType;
@@ -97,6 +104,11 @@
return this.maxConnection;
}
+ public int getTimeout()
+ {
+ return timeout;
+ }
+
public void setMaxConnection(int n)
{
this.maxConnection = n;
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 2011-09-13 12:58:47 UTC (rev 4902)
+++ core/trunk/exo.core.component.ldap/src/main/java/org/exoplatform/services/ldap/impl/LDAPServiceImpl.java 2011-09-13 13:08:32 UTC (rev 4903)
@@ -32,7 +32,6 @@
import java.io.File;
import java.util.HashMap;
import java.util.Hashtable;
-import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -85,8 +84,12 @@
env.put(Context.SECURITY_PRINCIPAL, config.getRootDN());
env.put(Context.SECURITY_CREDENTIALS, config.getPassword());
- PrivilegedSystemHelper.setProperty("com.sun.jndi.ldap.connect.timeout", "60000");
-
+ if (config.getTimeout() > 0)
+ {
+ PrivilegedSystemHelper.setProperty("com.sun.jndi.ldap.connect.pool.timeout",
+ Integer.toString(config.getTimeout()));
+ }
+
if (config.getMinConnection() > 0)
{
PrivilegedSystemHelper.setProperty("com.sun.jndi.ldap.connect.pool.initsize",
@@ -205,46 +208,6 @@
*/
public void addDeleteObject(ComponentPlugin plugin) throws NamingException
{
- if (false && plugin instanceof DeleteObjectCommand)
- {
- DeleteObjectCommand command = (DeleteObjectCommand)plugin;
- List<String> objectsToDelete = command.getObjectsToDelete();
- if (objectsToDelete == null || objectsToDelete.size() == 0)
- return;
- LdapContext ctx = getLdapContext();
- for (String name : objectsToDelete)
- {
- try
- {
- try
- {
- unbind(ctx, name);
- }
- catch (CommunicationException e1)
- {
- // create new LDAP context
- ctx = getLdapContext(true);
- // try repeat operation where communication error occurs
- unbind(ctx, name);
- }
- catch (ServiceUnavailableException e2)
- {
- // do the same as for CommunicationException
- ctx = getLdapContext(true);
- //
- unbind(ctx, name);
- }
- }
- catch (Exception e3)
- {
- // Catch all exceptions here.
- // Just inform about exception if it is not connection problem.
- LOG.error("Remove object (" + name + ") failed. ", e3);
- }
- }
- // close context
- release(ctx);
- }
}
private void unbind(LdapContext ctx, String name) throws NamingException
More information about the exo-jcr-commits
mailing list