This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/master by this push:
new 566d5f2 Update Commons Pool2
566d5f2 is described below
commit 566d5f220841374bed678c2615a40edc13e1c733
Author: Mark Thomas <[email protected]>
AuthorDate: Thu Aug 1 21:31:59 2019 +0100
Update Commons Pool2
---
MERGE.txt | 4 +--
.../org/apache/tomcat/dbcp/pool2/PooledObject.java | 39 ++++++++++++----------
.../tomcat/dbcp/pool2/PooledObjectState.java | 1 +
.../dbcp/pool2/impl/BaseGenericObjectPool.java | 2 +-
.../tomcat/dbcp/pool2/impl/CallStackUtils.java | 2 ++
.../dbcp/pool2/impl/DefaultPooledObject.java | 10 +++---
.../dbcp/pool2/impl/DefaultPooledObjectInfo.java | 6 +---
.../tomcat/dbcp/pool2/impl/EvictionTimer.java | 18 +++++-----
.../dbcp/pool2/impl/GenericKeyedObjectPool.java | 13 +++++---
.../tomcat/dbcp/pool2/impl/GenericObjectPool.java | 13 ++++----
.../tomcat/dbcp/pool2/impl/NoOpCallStack.java | 3 ++
.../tomcat/dbcp/pool2/impl/PoolImplUtils.java | 7 ++--
webapps/docs/changelog.xml | 4 +++
13 files changed, 69 insertions(+), 53 deletions(-)
diff --git a/MERGE.txt b/MERGE.txt
index a0e5a1c..dd72706 100644
--- a/MERGE.txt
+++ b/MERGE.txt
@@ -51,7 +51,7 @@ FileUpload
Sub-tree:
src/main/java/org/apache/commons/fileupload2
The SHA1 ID for the most recent commit to be merged to Tomcat is:
-41e40479f3000dc456d27951060fda01b87fbe9a (2019-04-24)
+9958ea2426ec5682a7c929a13372c04426ee3818 (2019-08-01)
Note: Tomcat's copy of fileupload also includes classes copied manually from
Commons IO.
@@ -69,4 +69,4 @@ Pool2
Sub-tree
src/main/java/org/apache/commons/pool2
The SHA1 ID for the most recent commit to be merged to Tomcat is:
-0664f4dac9ef653703624cbe67272134cf0151cb (2019-04-30)
+796e32d53cc0d870ba0db3a7faf4c5b24ff76f3f (2019-08-01)
diff --git a/java/org/apache/tomcat/dbcp/pool2/PooledObject.java
b/java/org/apache/tomcat/dbcp/pool2/PooledObject.java
index e437ee2..173a5d2 100644
--- a/java/org/apache/tomcat/dbcp/pool2/PooledObject.java
+++ b/java/org/apache/tomcat/dbcp/pool2/PooledObject.java
@@ -57,6 +57,16 @@ public interface PooledObject<T> extends
Comparable<PooledObject<T>> {
long getActiveTimeMillis();
/**
+ * Gets the number of times this object has been borrowed.
+ *
+ * @return -1 by default for old implementations prior to release 2.7.0.
+ * @since 2.7.0
+ */
+ default long getBorrowedCount() {
+ return -1;
+ }
+
+ /**
* Obtains the time in milliseconds that this object last spend in the
* idle state (it may still be idle in which case subsequent calls will
* return an increased value).
@@ -169,17 +179,17 @@ public interface PooledObject<T> extends
Comparable<PooledObject<T>> {
*/
void setLogAbandoned(boolean logAbandoned);
-// TODO: uncomment in 3.0 (API compatibility)
-// /**
-// * Configures the stack trace generation strategy based on whether or
not fully
-// * detailed stack traces are required. When set to false, abandoned logs
may
-// * only include caller class information rather than method names, line
numbers,
-// * and other normal metadata available in a full stack trace.
-// *
-// * @param requireFullStackTrace the new configuration setting for
abandoned object
-// * logging
-// */
-// void setRequireFullStackTrace(boolean requireFullStackTrace);
+ /**
+ * Configures the stack trace generation strategy based on whether or not
fully detailed stack traces are required.
+ * When set to false, abandoned logs may only include caller class
information rather than method names, line
+ * numbers, and other normal metadata available in a full stack trace.
+ *
+ * @param requireFullStackTrace the new configuration setting for
abandoned object logging
+ * @since 2.7.0
+ */
+ default void setRequireFullStackTrace(boolean requireFullStackTrace) {
+ // noop
+ }
/**
* Record the current stack trace as the last time the object was used.
@@ -210,11 +220,4 @@ public interface PooledObject<T> extends
Comparable<PooledObject<T>> {
* Marks the object as returning to the pool.
*/
void markReturning();
-
- // TODO: Uncomment this for version 3 (can't add it to 2.x as it will break
- // API compatibility)
- ///**
- // * Get the number of times this object has been borrowed.
- // */
- //long getBorrowedCount();
}
diff --git a/java/org/apache/tomcat/dbcp/pool2/PooledObjectState.java
b/java/org/apache/tomcat/dbcp/pool2/PooledObjectState.java
index f347fe0..fa522fd 100644
--- a/java/org/apache/tomcat/dbcp/pool2/PooledObjectState.java
+++ b/java/org/apache/tomcat/dbcp/pool2/PooledObjectState.java
@@ -22,6 +22,7 @@ package org.apache.tomcat.dbcp.pool2;
* @since 2.0
*/
public enum PooledObjectState {
+
/**
* In the queue, not in use.
*/
diff --git a/java/org/apache/tomcat/dbcp/pool2/impl/BaseGenericObjectPool.java
b/java/org/apache/tomcat/dbcp/pool2/impl/BaseGenericObjectPool.java
index 448c4a7..e37d42d 100644
--- a/java/org/apache/tomcat/dbcp/pool2/impl/BaseGenericObjectPool.java
+++ b/java/org/apache/tomcat/dbcp/pool2/impl/BaseGenericObjectPool.java
@@ -785,7 +785,7 @@ public abstract class BaseGenericObjectPool<T> extends
BaseObject {
/**
* Stops the evictor.
*/
- void stopEvitor() {
+ void stopEvictor() {
startEvictor(-1L);
}
/**
diff --git a/java/org/apache/tomcat/dbcp/pool2/impl/CallStackUtils.java
b/java/org/apache/tomcat/dbcp/pool2/impl/CallStackUtils.java
index 871f311..71db0e1 100644
--- a/java/org/apache/tomcat/dbcp/pool2/impl/CallStackUtils.java
+++ b/java/org/apache/tomcat/dbcp/pool2/impl/CallStackUtils.java
@@ -26,6 +26,8 @@ import java.security.AccessControlException;
public final class CallStackUtils {
/**
+ * Returns whether the caller can create a security manager in the current
environment.
+ *
* @return {@code true} if it is able to create a security manager in the
current environment, {@code false}
* otherwise.
*/
diff --git a/java/org/apache/tomcat/dbcp/pool2/impl/DefaultPooledObject.java
b/java/org/apache/tomcat/dbcp/pool2/impl/DefaultPooledObject.java
index 2ba5ea5..471a7fa 100644
--- a/java/org/apache/tomcat/dbcp/pool2/impl/DefaultPooledObject.java
+++ b/java/org/apache/tomcat/dbcp/pool2/impl/DefaultPooledObject.java
@@ -48,7 +48,7 @@ public class DefaultPooledObject<T> implements
PooledObject<T> {
private volatile long borrowedCount = 0;
/**
- * Create a new instance that wraps the provided object so that the pool
can
+ * Creates a new instance that wraps the provided object so that the pool
can
* track the state of the pooled object.
*
* @param object The object to wrap
@@ -99,16 +99,17 @@ public class DefaultPooledObject<T> implements
PooledObject<T> {
}
/**
- * Get the number of times this object has been borrowed.
+ * Gets the number of times this object has been borrowed.
* @return The number of times this object has been borrowed.
* @since 2.1
*/
+ @Override
public long getBorrowedCount() {
return borrowedCount;
}
/**
- * Return an estimate of the last time this object was used. If the class
+ * Returns an estimate of the last time this object was used. If the class
* of the pooled object implements {@link TrackedUse}, what is returned is
* the maximum of {@link TrackedUse#getLastUsed()} and
* {@link #getLastBorrowTime()}; otherwise this method gives the same
@@ -285,8 +286,7 @@ public class DefaultPooledObject<T> implements
PooledObject<T> {
* logging
* @since 2.5
*/
- // TODO: uncomment below in 3.0
- // @Override
+ @Override
public void setRequireFullStackTrace(final boolean requireFullStackTrace) {
borrowedBy = CallStackUtils.newCallStack("'Pooled object created' " +
"yyyy-MM-dd HH:mm:ss Z 'by the following code has not been
returned to the pool:'",
diff --git
a/java/org/apache/tomcat/dbcp/pool2/impl/DefaultPooledObjectInfo.java
b/java/org/apache/tomcat/dbcp/pool2/impl/DefaultPooledObjectInfo.java
index 89871ac..912878b 100644
--- a/java/org/apache/tomcat/dbcp/pool2/impl/DefaultPooledObjectInfo.java
+++ b/java/org/apache/tomcat/dbcp/pool2/impl/DefaultPooledObjectInfo.java
@@ -93,11 +93,7 @@ public class DefaultPooledObjectInfo implements
DefaultPooledObjectInfoMBean {
@Override
public long getBorrowedCount() {
- // TODO Simplify this once getBorrowedCount has been added to
PooledObject
- if (pooledObject instanceof DefaultPooledObject) {
- return ((DefaultPooledObject<?>) pooledObject).getBorrowedCount();
- }
- return -1;
+ return pooledObject.getBorrowedCount();
}
/**
diff --git a/java/org/apache/tomcat/dbcp/pool2/impl/EvictionTimer.java
b/java/org/apache/tomcat/dbcp/pool2/impl/EvictionTimer.java
index f034c38..46ded3f 100644
--- a/java/org/apache/tomcat/dbcp/pool2/impl/EvictionTimer.java
+++ b/java/org/apache/tomcat/dbcp/pool2/impl/EvictionTimer.java
@@ -46,7 +46,7 @@ class EvictionTimer {
/** Executor instance */
private static ScheduledThreadPoolExecutor executor;
//@GuardedBy("EvictionTimer.class")
- /** Prevent instantiation */
+ /** Prevents instantiation */
private EvictionTimer() {
// Hide the default constructor
}
@@ -64,14 +64,14 @@ class EvictionTimer {
/**
- * Add the specified eviction task to the timer. Tasks that are added with
a
+ * Adds the specified eviction task to the timer. Tasks that are added
with a
* call to this method *must* call {@link
#cancel(BaseGenericObjectPool.Evictor,long,TimeUnit)}
* to cancel the task to prevent memory and/or thread leaks in application
* server environments.
*
- * @param task Task to be scheduled
- * @param delay Delay in milliseconds before task is executed
- * @param period Time in milliseconds between executions
+ * @param task Task to be scheduled.
+ * @param delay Delay in milliseconds before task is executed.
+ * @param period Time in milliseconds between executions.
*/
static synchronized void schedule(
final BaseGenericObjectPool<?>.Evictor task, final long delay,
final long period) {
@@ -85,13 +85,13 @@ class EvictionTimer {
}
/**
- * Remove the specified eviction task from the timer.
+ * Removes the specified eviction task from the timer.
*
- * @param evictor Task to be cancelled
+ * @param evictor Task to be cancelled.
* @param timeout If the associated executor is no longer required, how
* long should this thread wait for the executor to
* terminate?
- * @param unit The units for the specified timeout
+ * @param unit The units for the specified timeout.
*/
static synchronized void cancel(
final BaseGenericObjectPool<?>.Evictor evictor, final long
timeout, final TimeUnit unit) {
@@ -119,7 +119,7 @@ class EvictionTimer {
@Override
public Thread newThread(final Runnable runnable) {
final Thread thread = new Thread(null, runnable,
"commons-pool-evictor-thread");
- thread.setDaemon(true); // POOL-363 - Required for applications
using Runtime.addShutdownHook(). --joshlandin 03.27.2019
+ thread.setDaemon(true); // POOL-363 - Required for applications
using Runtime.addShutdownHook().
AccessController.doPrivileged(new PrivilegedAction<Void>() {
@Override
public Void run() {
diff --git a/java/org/apache/tomcat/dbcp/pool2/impl/GenericKeyedObjectPool.java
b/java/org/apache/tomcat/dbcp/pool2/impl/GenericKeyedObjectPool.java
index 175631c..01dc542 100644
--- a/java/org/apache/tomcat/dbcp/pool2/impl/GenericKeyedObjectPool.java
+++ b/java/org/apache/tomcat/dbcp/pool2/impl/GenericKeyedObjectPool.java
@@ -382,7 +382,7 @@ public class GenericKeyedObjectPool<K, T> extends
BaseGenericObjectPool<T>
throw nsee;
}
}
- if (p != null && (getTestOnBorrow() || create &&
getTestOnCreate())) {
+ if (p != null && getTestOnBorrow()) {
boolean validate = false;
Throwable validationThrowable = null;
try {
@@ -520,8 +520,8 @@ public class GenericKeyedObjectPool<K, T> extends
BaseGenericObjectPool<T>
/**
* Whether there is at least one thread waiting on this deque, add an pool
object.
- * @param key
- * @param idleObjects
+ * @param key pool key.
+ * @param idleObjects list of idle pool objects.
*/
private void whenWaitersAddObject(final K key, final
LinkedBlockingDeque<PooledObject<T>> idleObjects) {
if (idleObjects.hasTakeWaiters()) {
@@ -689,7 +689,7 @@ public class GenericKeyedObjectPool<K, T> extends
BaseGenericObjectPool<T>
// Stop the evictor before the pool is closed since evict() calls
// assertOpen()
- stopEvitor();
+ stopEvictor();
closed = true;
// This clear removes any idle objects
@@ -1040,6 +1040,11 @@ public class GenericKeyedObjectPool<K, T> extends
BaseGenericObjectPool<T>
PooledObject<T> p = null;
try {
p = factory.makeObject(key);
+ if (getTestOnCreate() && !factory.validateObject(key, p)) {
+ numTotal.decrementAndGet();
+ objectDeque.getCreateCount().decrementAndGet();
+ return null;
+ }
} catch (final Exception e) {
numTotal.decrementAndGet();
objectDeque.getCreateCount().decrementAndGet();
diff --git a/java/org/apache/tomcat/dbcp/pool2/impl/GenericObjectPool.java
b/java/org/apache/tomcat/dbcp/pool2/impl/GenericObjectPool.java
index 04fdd79..c72b701 100644
--- a/java/org/apache/tomcat/dbcp/pool2/impl/GenericObjectPool.java
+++ b/java/org/apache/tomcat/dbcp/pool2/impl/GenericObjectPool.java
@@ -464,7 +464,7 @@ public class GenericObjectPool<T> extends
BaseGenericObjectPool<T>
throw nsee;
}
}
- if (p != null && (getTestOnBorrow() || create &&
getTestOnCreate())) {
+ if (p != null && getTestOnBorrow()) {
boolean validate = false;
Throwable validationThrowable = null;
try {
@@ -686,7 +686,7 @@ public class GenericObjectPool<T> extends
BaseGenericObjectPool<T>
// Stop the evictor before the pool is closed since evict() calls
// assertOpen()
- stopEvitor();
+ stopEvictor();
closed = true;
// This clear removes any idle objects
@@ -888,6 +888,10 @@ public class GenericObjectPool<T> extends
BaseGenericObjectPool<T>
final PooledObject<T> p;
try {
p = factory.makeObject();
+ if (getTestOnCreate() && !factory.validateObject(p)) {
+ createCount.decrementAndGet();
+ return null;
+ }
} catch (final Throwable e) {
createCount.decrementAndGet();
throw e;
@@ -901,10 +905,7 @@ public class GenericObjectPool<T> extends
BaseGenericObjectPool<T>
final AbandonedConfig ac = this.abandonedConfig;
if (ac != null && ac.getLogAbandoned()) {
p.setLogAbandoned(true);
- // TODO: in 3.0, this can use the method defined on PooledObject
- if (p instanceof DefaultPooledObject<?>) {
- ((DefaultPooledObject<T>)
p).setRequireFullStackTrace(ac.getRequireFullStackTrace());
- }
+ p.setRequireFullStackTrace(ac.getRequireFullStackTrace());
}
createdCount.incrementAndGet();
diff --git a/java/org/apache/tomcat/dbcp/pool2/impl/NoOpCallStack.java
b/java/org/apache/tomcat/dbcp/pool2/impl/NoOpCallStack.java
index 80a0825..f704182 100644
--- a/java/org/apache/tomcat/dbcp/pool2/impl/NoOpCallStack.java
+++ b/java/org/apache/tomcat/dbcp/pool2/impl/NoOpCallStack.java
@@ -31,6 +31,9 @@ public class NoOpCallStack implements CallStack {
*/
public static final CallStack INSTANCE = new NoOpCallStack();
+ /**
+ * Constructs the singleton instance.
+ */
private NoOpCallStack() {
}
diff --git a/java/org/apache/tomcat/dbcp/pool2/impl/PoolImplUtils.java
b/java/org/apache/tomcat/dbcp/pool2/impl/PoolImplUtils.java
index bfe0845..bee5179 100644
--- a/java/org/apache/tomcat/dbcp/pool2/impl/PoolImplUtils.java
+++ b/java/org/apache/tomcat/dbcp/pool2/impl/PoolImplUtils.java
@@ -108,11 +108,12 @@ class PoolImplUtils {
/**
* Gets the matching parameterized type or null.
* @param type
- * The interface that defines a generic type
+ * The interface that defines a generic type.
* @param clazz
- * The class that implements the interface with a concrete type
+ * The class that implements the interface with a concrete type.
* @param <T>
- * The interface type
+ * The interface type.
+ * @return the matching parameterized type or null.
*/
private static <T> ParameterizedType getParameterizedType(final Class<T>
type, final Class<? extends T> clazz) {
for (final Type iface : clazz.getGenericInterfaces()) {
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index e515188..0591676 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -217,6 +217,10 @@
Update the internal fork of Commons Codec to 3ebef4a (2018-08-01) to
pick up the fix for CODEC-134. (markt)
</update>
+ <update>
+ Update the internal fork of Commons Pool2 to 796e32d (2018-08-01) to
+ pick up the changes Commons Pool2 2.7.0. (markt)
+ </update>
</changelog>
</subsection>
</section>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]