Merge remote-tracking branch 'origin/master' into release
diff --git a/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java b/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java
index 0857929..17d2bd2 100644
--- a/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java
+++ b/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java
@@ -217,27 +217,32 @@
this.blockWhenExhausted = blockWhenExhausted;
}
- protected void setConfig(final BaseObjectPoolConfig<T> conf) {
- setLifo(conf.getLifo());
- setMaxWaitMillis(conf.getMaxWaitMillis());
- setBlockWhenExhausted(conf.getBlockWhenExhausted());
- setTestOnCreate(conf.getTestOnCreate());
- setTestOnBorrow(conf.getTestOnBorrow());
- setTestOnReturn(conf.getTestOnReturn());
- setTestWhileIdle(conf.getTestWhileIdle());
- setNumTestsPerEvictionRun(conf.getNumTestsPerEvictionRun());
- setMinEvictableIdleTimeMillis(conf.getMinEvictableIdleTimeMillis());
- setTimeBetweenEvictionRunsMillis(conf.getTimeBetweenEvictionRunsMillis());
- setSoftMinEvictableIdleTimeMillis(conf.getSoftMinEvictableIdleTimeMillis());
- final EvictionPolicy<T> policy = conf.getEvictionPolicy();
+ /**
+ * Initializes the receiver with the given configuration.
+ *
+ * @param config Initialization source.
+ */
+ protected void setConfig(final BaseObjectPoolConfig<T> config) {
+ setLifo(config.getLifo());
+ setMaxWaitMillis(config.getMaxWaitMillis());
+ setBlockWhenExhausted(config.getBlockWhenExhausted());
+ setTestOnCreate(config.getTestOnCreate());
+ setTestOnBorrow(config.getTestOnBorrow());
+ setTestOnReturn(config.getTestOnReturn());
+ setTestWhileIdle(config.getTestWhileIdle());
+ setNumTestsPerEvictionRun(config.getNumTestsPerEvictionRun());
+ setMinEvictableIdleTimeMillis(config.getMinEvictableIdleTimeMillis());
+ setTimeBetweenEvictionRunsMillis(config.getTimeBetweenEvictionRunsMillis());
+ setSoftMinEvictableIdleTimeMillis(config.getSoftMinEvictableIdleTimeMillis());
+ final EvictionPolicy<T> policy = config.getEvictionPolicy();
if (policy == null) {
// Use the class name (pre-2.6.0 compatible)
- setEvictionPolicyClassName(conf.getEvictionPolicyClassName());
+ setEvictionPolicyClassName(config.getEvictionPolicyClassName());
} else {
// Otherwise, use the class (2.6.0 feature)
setEvictionPolicy(policy);
}
- setEvictorShutdownTimeoutMillis(conf.getEvictorShutdownTimeoutMillis());
+ setEvictorShutdownTimeoutMillis(config.getEvictorShutdownTimeoutMillis());
}
/**
@@ -653,16 +658,22 @@
setEvictionPolicy(evictionPolicyClassName, epClassLoader);
}
} catch (final ClassCastException e) {
- throw new IllegalArgumentException("Class " + evictionPolicyClassName + " from class loaders ["
- + classLoader + ", " + epClassLoader + "] do not implement " + EVICTION_POLICY_TYPE_NAME);
- } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException
- | InvocationTargetException | NoSuchMethodException e) {
- final String exMessage = "Unable to create " + EVICTION_POLICY_TYPE_NAME + " instance of type "
- + evictionPolicyClassName;
+ throw new IllegalArgumentException("Class " + evictionPolicyClassName + " from class loaders [" +
+ classLoader + ", " + epClassLoader + "] do not implement " + EVICTION_POLICY_TYPE_NAME);
+ } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException |
+ InvocationTargetException | NoSuchMethodException e) {
+ final String exMessage = "Unable to create " + EVICTION_POLICY_TYPE_NAME + " instance of type " +
+ evictionPolicyClassName;
throw new IllegalArgumentException(exMessage, e);
}
}
+ /**
+ * Sets the eviction policy.
+ *
+ * @param className Eviction policy class name.
+ * @param classLoader Load the class from this class loader.
+ */
@SuppressWarnings("unchecked")
private void setEvictionPolicy(final String className, final ClassLoader classLoader)
throws ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
@@ -1156,11 +1167,19 @@
}
+ /**
+ * Sets the scheduled future.
+ *
+ * @param scheduledFuture the scheduled future.
+ */
void setScheduledFuture(final ScheduledFuture<?> scheduledFuture) {
this.scheduledFuture = scheduledFuture;
}
+ /**
+ * Cancels the scheduled future.
+ */
void cancel() {
scheduledFuture.cancel(false);
}
diff --git a/src/main/java/org/apache/commons/pool2/impl/CallStackUtils.java b/src/main/java/org/apache/commons/pool2/impl/CallStackUtils.java
index c1bff0a..6b132a9 100644
--- a/src/main/java/org/apache/commons/pool2/impl/CallStackUtils.java
+++ b/src/main/java/org/apache/commons/pool2/impl/CallStackUtils.java
@@ -72,9 +72,9 @@
public static CallStack newCallStack(final String messageFormat,
final boolean useTimestamp,
final boolean requireFullStackTrace) {
- return canCreateSecurityManager() && !requireFullStackTrace
- ? new SecurityManagerCallStack(messageFormat, useTimestamp)
- : new ThrowableCallStack(messageFormat, useTimestamp);
+ return canCreateSecurityManager() && !requireFullStackTrace ?
+ new SecurityManagerCallStack(messageFormat, useTimestamp) :
+ new ThrowableCallStack(messageFormat, useTimestamp);
}
/**