Author: markt
Date: Mon Dec 8 13:28:01 2014
New Revision: 1643815
URL: http://svn.apache.org/r1643815
Log:
Update fork of Apache Commons Pool2 to latest trunk to pick up fixes including
one for a potential infinite loop.
Modified:
tomcat/tc8.0.x/trunk/ (props changed)
tomcat/tc8.0.x/trunk/java/org/apache/tomcat/dbcp/pool2/ (props changed)
tomcat/tc8.0.x/trunk/java/org/apache/tomcat/dbcp/pool2/impl/BaseGenericObjectPool.java
tomcat/tc8.0.x/trunk/java/org/apache/tomcat/dbcp/pool2/impl/DefaultPooledObject.java
tomcat/tc8.0.x/trunk/java/org/apache/tomcat/dbcp/pool2/impl/LinkedBlockingDeque.java
tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml
Propchange: tomcat/tc8.0.x/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Dec 8 13:28:01 2014
@@ -1 +1 @@
-/tomcat/trunk:1636524,1637156,1637176,1637188,1637331,1637684,1637695,1638720-1638725,1639653,1640010,1640084,1640088,1640275,1640322,1640347,1640361,1640365,1640403,1640410,1640652,1640655-1640658,1640688,1640700-1640883,1640903,1640976,1640978,1641000,1641026,1641038-1641039,1641051-1641052,1641058,1641064,1641300,1641369,1641374,1641380,1641486,1641634,1641656-1641692,1641704,1641707-1641718,1641720-1641722,1641735,1641981,1642554,1642564,1642595,1642606,1642668,1642679,1642697,1642699,1643002,1643045,1643054-1643055,1643066,1643121,1643206,1643209-1643210,1643216,1643249,1643270,1643283,1643309-1643310,1643323,1643365-1643366,1643370-1643371,1643465,1643474,1643570,1643634,1643649,1643651,1643654,1643675,1643731,1643733-1643734,1643761,1643766
+/tomcat/trunk:1636524,1637156,1637176,1637188,1637331,1637684,1637695,1638720-1638725,1639653,1640010,1640084,1640088,1640275,1640322,1640347,1640361,1640365,1640403,1640410,1640652,1640655-1640658,1640688,1640700-1640883,1640903,1640976,1640978,1641000,1641026,1641038-1641039,1641051-1641052,1641058,1641064,1641300,1641369,1641374,1641380,1641486,1641634,1641656-1641692,1641704,1641707-1641718,1641720-1641722,1641735,1641981,1642554,1642564,1642595,1642606,1642668,1642679,1642697,1642699,1643002,1643045,1643054-1643055,1643066,1643121,1643206,1643209-1643210,1643216,1643249,1643270,1643283,1643309-1643310,1643323,1643365-1643366,1643370-1643371,1643465,1643474,1643570,1643634,1643649,1643651,1643654,1643675,1643731,1643733-1643734,1643761,1643766,1643814
Propchange: tomcat/tc8.0.x/trunk/java/org/apache/tomcat/dbcp/pool2/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Dec 8 13:28:01 2014
@@ -1 +1,2 @@
-/commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2:1593516-1627271
+/commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2:1593516-1643813
+/tomcat/trunk/java/org/apache/tomcat/dbcp/pool2:1643814
Modified:
tomcat/tc8.0.x/trunk/java/org/apache/tomcat/dbcp/pool2/impl/BaseGenericObjectPool.java
URL:
http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/java/org/apache/tomcat/dbcp/pool2/impl/BaseGenericObjectPool.java?rev=1643815&r1=1643814&r2=1643815&view=diff
==============================================================================
---
tomcat/tc8.0.x/trunk/java/org/apache/tomcat/dbcp/pool2/impl/BaseGenericObjectPool.java
(original)
+++
tomcat/tc8.0.x/trunk/java/org/apache/tomcat/dbcp/pool2/impl/BaseGenericObjectPool.java
Mon Dec 8 13:28:01 2014
@@ -111,8 +111,7 @@ public abstract class BaseGenericObjectP
private final StatsStore activeTimes = new
StatsStore(MEAN_TIMING_STATS_CACHE_SIZE);
private final StatsStore idleTimes = new
StatsStore(MEAN_TIMING_STATS_CACHE_SIZE);
private final StatsStore waitTimes = new
StatsStore(MEAN_TIMING_STATS_CACHE_SIZE);
- private final Object maxBorrowWaitTimeMillisLock = new Object();
- private volatile long maxBorrowWaitTimeMillis = 0; //
@GuardedBy("maxBorrowWaitTimeMillisLock")
+ private final AtomicLong maxBorrowWaitTimeMillis = new AtomicLong(0L);
private volatile SwallowedExceptionListener swallowedExceptionListener =
null;
@@ -809,7 +808,7 @@ public abstract class BaseGenericObjectP
* @return maximum wait time in milliseconds since the pool was created
*/
public final long getMaxBorrowWaitTimeMillis() {
- return maxBorrowWaitTimeMillis;
+ return maxBorrowWaitTimeMillis.get();
}
/**
@@ -873,11 +872,15 @@ public abstract class BaseGenericObjectP
borrowedCount.incrementAndGet();
idleTimes.add(p.getIdleTimeMillis());
waitTimes.add(waitTime);
- synchronized (maxBorrowWaitTimeMillisLock) {
- if (waitTime > maxBorrowWaitTimeMillis) {
- maxBorrowWaitTimeMillis = waitTime;
+
+ // lock-free optimistic-locking maximum
+ long currentMax;
+ do {
+ currentMax = maxBorrowWaitTimeMillis.get();
+ if (currentMax >= waitTime) {
+ break;
}
- }
+ } while (!maxBorrowWaitTimeMillis.compareAndSet(currentMax, waitTime));
}
/**
@@ -1039,12 +1042,21 @@ public abstract class BaseGenericObjectP
}
}
+ /**
+ * Maintains a cache of values for a single metric and reports
+ * statistics on the cached values.
+ */
private class StatsStore {
private final AtomicLong values[];
private final int size;
private int index;
+ /**
+ * Create a StatsStore with the given cache size.
+ *
+ * @param size number of values to maintain in the cache.
+ */
public StatsStore(int size) {
this.size = size;
values = new AtomicLong[size];
@@ -1053,6 +1065,12 @@ public abstract class BaseGenericObjectP
}
}
+ /**
+ * Adds a value to the cache. If the cache is full, one of the
+ * existing values is replaced by the new value.
+ *
+ * @param value new value to add to the cache.
+ */
public synchronized void add(long value) {
values[index].set(value);
index++;
@@ -1061,6 +1079,11 @@ public abstract class BaseGenericObjectP
}
}
+ /**
+ * Returns the mean of the cached values.
+ *
+ * @return the mean of the cache, truncated to long
+ */
public long getMean() {
double result = 0;
int counter = 0;
@@ -1073,7 +1096,6 @@ public abstract class BaseGenericObjectP
}
}
return (long) result;
-
}
}
}
Modified:
tomcat/tc8.0.x/trunk/java/org/apache/tomcat/dbcp/pool2/impl/DefaultPooledObject.java
URL:
http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/java/org/apache/tomcat/dbcp/pool2/impl/DefaultPooledObject.java?rev=1643815&r1=1643814&r2=1643815&view=diff
==============================================================================
---
tomcat/tc8.0.x/trunk/java/org/apache/tomcat/dbcp/pool2/impl/DefaultPooledObject.java
(original)
+++
tomcat/tc8.0.x/trunk/java/org/apache/tomcat/dbcp/pool2/impl/DefaultPooledObject.java
Mon Dec 8 13:28:01 2014
@@ -289,7 +289,7 @@ public class DefaultPooledObject<T> impl
private static final long serialVersionUID = 7398692158058772916L;
/** Date format */
- //@GuardedBy("this")
+ //@GuardedBy("format")
private static final SimpleDateFormat format = new SimpleDateFormat
("'Pooled object created' yyyy-MM-dd HH:mm:ss Z " +
"'by the following code has not been returned to the pool:'");
Modified:
tomcat/tc8.0.x/trunk/java/org/apache/tomcat/dbcp/pool2/impl/LinkedBlockingDeque.java
URL:
http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/java/org/apache/tomcat/dbcp/pool2/impl/LinkedBlockingDeque.java?rev=1643815&r1=1643814&r2=1643815&view=diff
==============================================================================
---
tomcat/tc8.0.x/trunk/java/org/apache/tomcat/dbcp/pool2/impl/LinkedBlockingDeque.java
(original)
+++
tomcat/tc8.0.x/trunk/java/org/apache/tomcat/dbcp/pool2/impl/LinkedBlockingDeque.java
Mon Dec 8 13:28:01 2014
@@ -1226,23 +1226,33 @@ class LinkedBlockingDeque<E> extends Abs
}
/**
+ * Returns the successor node of the given non-null, but
+ * possibly previously deleted, node.
+ */
+ private Node<E> succ(Node<E> n) {
+ // Chains of deleted nodes ending in null or self-links
+ // are possible if multiple interior nodes are removed.
+ for (;;) {
+ Node<E> s = nextNode(n);
+ if (s == null)
+ return null;
+ else if (s.item != null)
+ return s;
+ else if (s == n)
+ return firstNode();
+ else
+ n = s;
+ }
+ }
+
+ /**
* Advances next.
*/
void advance() {
lock.lock();
try {
// assert next != null;
- Node<E> s = nextNode(next);
- if (s == next) {
- next = firstNode();
- } else {
- // Skip over removed nodes.
- // May be necessary if multiple interior Nodes are removed.
- while (s != null && s.item == null) {
- s = nextNode(s);
- }
- next = s;
- }
+ next = succ(next);
nextItem = next == null ? null : next.item;
} finally {
lock.unlock();
Modified: tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml?rev=1643815&r1=1643814&r2=1643815&view=diff
==============================================================================
--- tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml Mon Dec 8 13:28:01 2014
@@ -243,6 +243,11 @@
project that uses Java 7 compliance settings instead of workspace-wide
defaults. (kkolinko)
</fix>
+ <fix>
+ Update the package renamed copy of Apache Commons Pool 2 to revision
+ 1643813 to pick up additional fixes since the 2.2 release including
+ one for a possible infinite loop. (markt)
+ </fix>
</changelog>
</subsection>
</section>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]