rwinch / spring-ldap

Apache License 2.0
0 stars 0 forks source link

LDAP-230: Pool Validation polluting logs with "IOException: connection closed" stacktrace even though it is handled gracefully by framework #114

Closed rwinch closed 8 years ago

rwinch commented 13 years ago

Original Reporter: timothyja Environment: Not Specified Version: 1.3.0 Migrated From: https://jira.spring.io//browse/LDAP-230 In the DefaultDirContextValidator class the validateObject method catches this exception when an object in the object pool has become invalid. This is an expected outcome and is handled by the framework.

The problem is that when caught the exception is logged as a warning and the exception stack trace dumped to the logs, as this is not a rare event logs are subsiquently littered with this stacktrace and warnings.

Notes:

We use DefaultDirContextValidator in conjunction with the testOnBorrow Pooling setting.

Offending Code:

 catch (Exception e) {
   this.logger.warn("DirContext '" + dirContext + "' failed validation with an exception.", e);
 }

if (this.logger.isInfoEnabled()) {
   this.logger.info("DirContext '" + dirContext + "' failed validation.");
 }

Stack Trace:

[11/07/11 09:01:53:070 EST] 00000077 DefaultDirCon I org.springframework.ldap.pool.validation.DefaultDirContextValidator validateDirContext DirContext 'javax.naming.ldap.InitialLdapContext@1ace4fd' failed validation. [11/07/11 09:08:59:130 EST] 00000085 DefaultDirCon W org.springframework.ldap.pool.validation.DefaultDirContextValidator validateDirContext DirContext 'javax.naming.ldap.InitialLdapContext@14e0984' failed validation with an exception. javax.naming.CommunicationException: connection closed [Root exception is java.io.IOException: connection closed]; remaining name '' at com.sun.jndi.ldap.LdapCtx.doSearch(LdapCtx.java:1973) at com.sun.jndi.ldap.LdapCtx.searchAux(LdapCtx.java:1818) at com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:1743) at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(ComponentDirContext.java:368) at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:328) at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:313) at javax.naming.directory.InitialDirContext.search(InitialDirContext.java:238) at org.springframework.ldap.pool.validation.DefaultDirContextValidator.validateDirContext(DefaultDirContextValidator.java:154) at org.springframework.ldap.pool.factory.DirContextPoolableObjectFactory.validateObject(DirContextPoolableObjectFactory.java:169) at org.apache.commons.pool.impl.GenericKeyedObjectPool.borrowObject(GenericKeyedObjectPool.java:780) at org.springframework.ldap.pool.factory.PoolingContextSource.getContext(PoolingContextSource.java:394) at org.springframework.ldap.pool.factory.PoolingContextSource.getReadOnlyContext(PoolingContextSource.java:374) at org.springframework.ldap.core.LdapTemplate.executeReadOnly(LdapTemplate.java:770) at org.springframework.ldap.core.LdapTemplate.lookup(LdapTemplate.java:865)

rwinch commented 13 years ago

timothyja said: I have attached my suggested patch to tone down these expected warnings

rwinch commented 11 years ago

marthursson said: Modified log levels according to suggestion.