diff --git a/core/src/main/java/org/springframework/ldap/pool/factory/DirContextPoolableObjectFactory.java b/core/src/main/java/org/springframework/ldap/pool/factory/DirContextPoolableObjectFactory.java index 80e3671c..ad348fdc 100644 --- a/core/src/main/java/org/springframework/ldap/pool/factory/DirContextPoolableObjectFactory.java +++ b/core/src/main/java/org/springframework/ldap/pool/factory/DirContextPoolableObjectFactory.java @@ -273,10 +273,19 @@ class DirContextPoolableObjectFactory extends BaseKeyedPoolableObjectFactory { catch (InvocationTargetException e) { Throwable targetException = e.getTargetException(); Class targetExceptionClass = targetException.getClass(); - if(nonTransientExceptions.contains(targetExceptionClass)) { - logger.info( - String.format("An %s - explicitly configured to be a non-transient exception - encountered; eagerly invalidating the target context.", - targetExceptionClass)); + + boolean nonTransientEncountered = false; + for (Class clazz : nonTransientExceptions) { + if(clazz.isAssignableFrom(targetExceptionClass)) { + logger.info( + String.format("An %s - explicitly configured to be a non-transient exception - encountered; eagerly invalidating the target context.", + targetExceptionClass)); + nonTransientEncountered = true; + break; + } + } + + if(nonTransientEncountered) { hasFailed = true; } else { if (logger.isDebugEnabled()) { diff --git a/core/src/main/java/org/springframework/ldap/pool/factory/PoolingContextSource.java b/core/src/main/java/org/springframework/ldap/pool/factory/PoolingContextSource.java index 283d106b..25b1a9df 100644 --- a/core/src/main/java/org/springframework/ldap/pool/factory/PoolingContextSource.java +++ b/core/src/main/java/org/springframework/ldap/pool/factory/PoolingContextSource.java @@ -379,10 +379,11 @@ public class PoolingContextSource implements ContextSource, DisposableBean { /** * Configure the exception classes that are to be interpreted as no-transient with regards to eager - * context invalidation. If one of the configured exceptions is thrown by any method on a pooled - * DirContext, that instance will immediately be marked as invalid without any additional testing - * (i.e. testOnReturn). This allows for more efficient management of dead connections. Default is - * {@link javax.naming.CommunicationException}. + * context invalidation. If one of the configured exceptions (or subclasses of them) + * is thrown by any method on a pooled DirContext, that instance will immediately be marked + * as invalid without any additional testing (i.e. testOnReturn). + * This allows for more efficient management of dead connections. + * Default is {@link javax.naming.CommunicationException}. * * @param nonTransientExceptions the exception classes that should be interpreted as non-transient * with regards to eager invalidation. diff --git a/src/docbkx/pooling.xml b/src/docbkx/pooling.xml index 5eca8f1e..4c1cf110 100644 --- a/src/docbkx/pooling.xml +++ b/src/docbkx/pooling.xml @@ -430,10 +430,10 @@ The Exceptions that should be considered non-transient with - regards to eager invalidation. Should any of the listed exceptions be - thrown by a call to a pooled DirContext instance, - that object will be automatically invalidated without any additional - testOnReturn operation. + regards to eager invalidation. Should any of the listed exceptions + (or subclasses of them) be thrown by a call to a + pooled DirContext instance, that object will be + automatically invalidated without any additional testOnReturn operation.