LDAP-101: Now also considering subclasses of defined non-transient exceptions.

This commit is contained in:
Mattias Hellborg Arthursson
2013-09-11 10:48:35 +02:00
parent 9687edf625
commit 9551905527
3 changed files with 22 additions and 12 deletions

View File

@@ -273,10 +273,19 @@ class DirContextPoolableObjectFactory extends BaseKeyedPoolableObjectFactory {
catch (InvocationTargetException e) {
Throwable targetException = e.getTargetException();
Class<? extends Throwable> 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<? extends Throwable> 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()) {

View File

@@ -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.

View File

@@ -430,10 +430,10 @@
<entry>
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 <literal>DirContext</literal> 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 <literal>DirContext</literal> instance, that object will be
automatically invalidated without any additional testOnReturn operation.
</entry>
</row>
</tbody>