LDAP-101: Now also considering subclasses of defined non-transient exceptions.
This commit is contained in:
@@ -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()) {
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user