Commit e0f0f6b7 authored by Emmanuel Bourg's avatar Emmanuel Bourg

New upstream version 2.6.2

parent 9b0a7baa
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
language: java
sudo: false
jdk:
- openjdk7
- openjdk8
- openjdk11
- openjdk12
- oraclejdk8
- oraclejdk9
- oraclejdk11
script:
- mvn
after_success:
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
language: java
sudo: false
jdk:
- openjdk7
- openjdk8
- openjdk11
- openjdk12
- oraclejdk8
- oraclejdk11
script:
- mvn
after_success:
- mvn clean cobertura:cobertura coveralls:report -Ptravis-cobertura
\ No newline at end of file
......@@ -46,7 +46,7 @@ Apache Commons Pool
[![Build Status](https://travis-ci.org/apache/commons-pool.svg)](https://travis-ci.org/apache/commons-pool)
[![Coverage Status](https://coveralls.io/repos/apache/commons-pool/badge.svg)](https://coveralls.io/r/apache/commons-pool)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.apache.commons/commons-pool2/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.apache.commons/commons-pool2/)
[![Javadocs](https://javadoc.io/badge/org.apache.commons/commons-pool2/2.6.1.svg)](https://javadoc.io/doc/org.apache.commons/commons-pool2/2.6.1)
[![Javadocs](https://javadoc.io/badge/org.apache.commons/commons-pool2/2.6.2.svg)](https://javadoc.io/doc/org.apache.commons/commons-pool2/2.6.2)
The Apache Commons Object Pooling Library.
......@@ -54,7 +54,7 @@ Documentation
-------------
More information can be found on the [Apache Commons Pool homepage](https://commons.apache.org/proper/commons-pool).
The [Javadoc](https://commons.apache.org/proper/commons-pool/javadocs/api-release) can be browsed.
The [Javadoc](https://commons.apache.org/proper/commons-pool/apidocs) can be browsed.
Questions related to the usage of Apache Commons Pool should be posted to the [user mailing list][ml].
Where can I get the latest release?
......@@ -67,7 +67,7 @@ Alternatively you can pull it from the central Maven repositories:
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>2.6.1</version>
<version>2.6.2</version>
</dependency>
```
......
Apache Commons Pool 2.6.2 RELEASE NOTES
The Apache Commons Pool team is pleased to announce the release of Apache Commons Pool 2.6.2.
Apache Commons Pool provides an object-pooling API and a number of object pool implementations.
Version 2 contains a completely re-written pooling implementation compared to the 1.x series.
In addition to performance and scalability improvements, version 2 includes robust instance
tracking and pool monitoring. Version 2 requires JDK level 1.6 or above.
No client code changes are required to migrate from versions 2.0-2.3 to version 2.4.3.
Users of version 1.x should consult the migration guide on the Commons Pool web site.
NOTE: The MBean interfaces (DefaultPooledObjectInfoMBean, GenericKeyedObjectPoolMXBean
and GenericKeyedObjectPoolMXBean) exist only to define the attributes and methods
that will be made available via JMX. They must not be implemented by clients as
they are subject to change between major, minor and patch version releases of
Commons Pool. Clients that implement any of these interfaces may not, therefore,
be able to upgrade to a new minor or patch release without requiring code
changes.
This is a maintenance release.
Changes in version 2.6.2 include:
Fixed Bugs:
o POOL-362: Always null out org.apache.commons.pool2.impl.BaseGenericObjectPool.evictionIterator to match org.apache.commons.pool2.impl.BaseGenericObjectPool.evictor.
o POOL-363: Evictor Thread prevents Spring Context shutdown in standalone app. Thanks to Josh Landin.
o POOL-348: The commons-pool-evictor-thread should run as a Deamon. Thanks to Josh Landin.
For complete information on Apache Commons Pool, including instructions on how to submit bug reports,
patches, or suggestions for improvement, see the Apache Apache Commons Pool website:
http://commons.apache.org/proper/commons-pool/
Download page: http://commons.apache.org/proper/commons-pool/download_pool.cgi
-----------------------------------------------------------------------------------------------
Apache Commons Pool 2.6.1 RELEASE NOTES
The Apache Commons Pool team is pleased to announce the release of Apache Commons Pool 2.6.1.
......
......@@ -24,11 +24,11 @@
<parent>
<groupId>org.apache.commons</groupId>
<artifactId>commons-parent</artifactId>
<version>47</version>
<version>48</version>
</parent>
<artifactId>commons-pool2</artifactId>
<version>2.6.1</version>
<version>2.6.2</version>
<name>Apache Commons Pool</name>
<inceptionYear>2001</inceptionYear>
......@@ -135,6 +135,7 @@
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-util</artifactId>
<!-- Version 7.1 depends on Java 8 -->
<version>7.0</version>
<optional>true</optional>
</dependency>
......@@ -157,9 +158,9 @@
<maven.compiler.target>1.7</maven.compiler.target>
<commons.componentid>pool</commons.componentid>
<commons.module.name>org.apache.commons.pool2</commons.module.name>
<commons.rc.version>RC2</commons.rc.version>
<commons.rc.version>RC1</commons.rc.version>
<!-- Java 7 -->
<commons.release.version>2.6.1</commons.release.version>
<commons.release.version>2.6.2</commons.release.version>
<commons.release.desc>(Java 7)</commons.release.desc>
<!-- Java 6 -->
<commons.release.2.version>2.4.3</commons.release.2.version>
......@@ -176,12 +177,13 @@
<commons.animal-sniffer.version>1.16</commons.animal-sniffer.version>
<!-- Commons Release Plugin -->
<commons.bc.version>2.6.0</commons.bc.version>
<commons.bc.version>2.6.1</commons.bc.version>
<commons.release.isDistModule>true</commons.release.isDistModule>
<commons.releaseManagerName>Gary Gregory</commons.releaseManagerName>
<commons.releaseManagerKey>86fdc7e2a11262cb</commons.releaseManagerKey>
<commons.japicmp.version>0.13.0</commons.japicmp.version>
<commons.japicmp.version>0.13.1</commons.japicmp.version>
<japicmp.skip>false</japicmp.skip>
</properties>
<build>
......@@ -206,7 +208,7 @@
<dependency>
<groupId>org.apache.bcel</groupId>
<artifactId>bcel</artifactId>
<version>6.3</version>
<version>6.3.1</version>
</dependency>
</dependencies>
</plugin>
......
This diff is collapsed.
......@@ -36,6 +36,13 @@ import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
*/
public final class PoolUtils {
private static final String MSG_FACTOR_NEGATIVE = "factor must be positive.";
private static final String MSG_MIN_IDLE = "minIdle must be non-negative.";
private static final String MSG_NULL_KEY = "key must not be null.";
private static final String MSG_NULL_KEYED_POOL = "keyedPool must not be null.";
private static final String MSG_NULL_KEYS = "keys must not be null.";
private static final String MSG_NULL_POOL = "pool must not be null.";
/**
* Timer used to periodically check pools idle object count. Because a
* {@link Timer} creates a {@link Thread}, an IODH is used.
......@@ -101,10 +108,10 @@ public final class PoolUtils {
final int minIdle, final long period)
throws IllegalArgumentException {
if (pool == null) {
throw new IllegalArgumentException("keyedPool must not be null.");
throw new IllegalArgumentException(MSG_NULL_KEYED_POOL);
}
if (minIdle < 0) {
throw new IllegalArgumentException("minIdle must be non-negative.");
throw new IllegalArgumentException(MSG_MIN_IDLE);
}
final TimerTask task = new ObjectPoolMinIdleTimerTask<>(pool, minIdle);
getMinIdleTimer().schedule(task, 0L, period);
......@@ -142,13 +149,13 @@ public final class PoolUtils {
final int minIdle, final long period)
throws IllegalArgumentException {
if (keyedPool == null) {
throw new IllegalArgumentException("keyedPool must not be null.");
throw new IllegalArgumentException(MSG_NULL_KEYED_POOL);
}
if (key == null) {
throw new IllegalArgumentException("key must not be null.");
throw new IllegalArgumentException(MSG_NULL_KEY);
}
if (minIdle < 0) {
throw new IllegalArgumentException("minIdle must be non-negative.");
throw new IllegalArgumentException(MSG_MIN_IDLE);
}
final TimerTask task = new KeyedObjectPoolMinIdleTimerTask<>(
keyedPool, key, minIdle);
......@@ -188,7 +195,7 @@ public final class PoolUtils {
final int minIdle, final long period)
throws IllegalArgumentException {
if (keys == null) {
throw new IllegalArgumentException("keys must not be null.");
throw new IllegalArgumentException(MSG_NULL_KEYS);
}
final Map<K, TimerTask> tasks = new HashMap<>(keys.size());
final Iterator<K> iter = keys.iterator();
......@@ -217,7 +224,7 @@ public final class PoolUtils {
public static <T> void prefill(final ObjectPool<T> pool, final int count)
throws Exception, IllegalArgumentException {
if (pool == null) {
throw new IllegalArgumentException("pool must not be null.");
throw new IllegalArgumentException(MSG_NULL_POOL);
}
for (int i = 0; i < count; i++) {
pool.addObject();
......@@ -246,10 +253,10 @@ public final class PoolUtils {
final K key, final int count) throws Exception,
IllegalArgumentException {
if (keyedPool == null) {
throw new IllegalArgumentException("keyedPool must not be null.");
throw new IllegalArgumentException(MSG_NULL_KEYED_POOL);
}
if (key == null) {
throw new IllegalArgumentException("key must not be null.");
throw new IllegalArgumentException(MSG_NULL_KEY);
}
for (int i = 0; i < count; i++) {
keyedPool.addObject(key);
......@@ -281,7 +288,7 @@ public final class PoolUtils {
final Collection<K> keys, final int count) throws Exception,
IllegalArgumentException {
if (keys == null) {
throw new IllegalArgumentException("keys must not be null.");
throw new IllegalArgumentException(MSG_NULL_KEYS);
}
final Iterator<K> iter = keys.iterator();
while (iter.hasNext()) {
......@@ -308,7 +315,7 @@ public final class PoolUtils {
*/
public static <T> ObjectPool<T> synchronizedPool(final ObjectPool<T> pool) {
if (pool == null) {
throw new IllegalArgumentException("pool must not be null.");
throw new IllegalArgumentException(MSG_NULL_POOL);
}
/*
* assert !(pool instanceof GenericObjectPool) :
......@@ -436,10 +443,10 @@ public final class PoolUtils {
public static <T> ObjectPool<T> erodingPool(final ObjectPool<T> pool,
final float factor) {
if (pool == null) {
throw new IllegalArgumentException("pool must not be null.");
throw new IllegalArgumentException(MSG_NULL_POOL);
}
if (factor <= 0f) {
throw new IllegalArgumentException("factor must be positive.");
throw new IllegalArgumentException(MSG_FACTOR_NEGATIVE);
}
return new ErodingObjectPool<>(pool, factor);
}
......@@ -538,10 +545,10 @@ public final class PoolUtils {
final KeyedObjectPool<K, V> keyedPool, final float factor,
final boolean perKey) {
if (keyedPool == null) {
throw new IllegalArgumentException("keyedPool must not be null.");
throw new IllegalArgumentException(MSG_NULL_KEYED_POOL);
}
if (factor <= 0f) {
throw new IllegalArgumentException("factor must be positive.");
throw new IllegalArgumentException(MSG_FACTOR_NEGATIVE);
}
if (perKey) {
return new ErodingPerKeyKeyedObjectPool<>(keyedPool, factor);
......@@ -587,7 +594,7 @@ public final class PoolUtils {
ObjectPoolMinIdleTimerTask(final ObjectPool<T> pool, final int minIdle)
throws IllegalArgumentException {
if (pool == null) {
throw new IllegalArgumentException("pool must not be null.");
throw new IllegalArgumentException(MSG_NULL_POOL);
}
this.pool = pool;
this.minIdle = minIdle;
......@@ -665,7 +672,7 @@ public final class PoolUtils {
final K key, final int minIdle) throws IllegalArgumentException {
if (keyedPool == null) {
throw new IllegalArgumentException(
"keyedPool must not be null.");
MSG_NULL_KEYED_POOL);
}
this.keyedPool = keyedPool;
this.key = key;
......@@ -747,7 +754,7 @@ public final class PoolUtils {
SynchronizedObjectPool(final ObjectPool<T> pool)
throws IllegalArgumentException {
if (pool == null) {
throw new IllegalArgumentException("pool must not be null.");
throw new IllegalArgumentException(MSG_NULL_POOL);
}
this.pool = pool;
}
......@@ -924,7 +931,7 @@ public final class PoolUtils {
throws IllegalArgumentException {
if (keyedPool == null) {
throw new IllegalArgumentException(
"keyedPool must not be null.");
MSG_NULL_KEYED_POOL);
}
this.keyedPool = keyedPool;
}
......@@ -1605,7 +1612,7 @@ public final class PoolUtils {
final ErodingFactor erodingFactor) {
if (keyedPool == null) {
throw new IllegalArgumentException(
"keyedPool must not be null.");
MSG_NULL_KEYED_POOL);
}
this.keyedPool = keyedPool;
this.erodingFactor = erodingFactor;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -36,6 +36,8 @@
<item name="Javadoc 2.4.3" href="http://commons.apache.org/proper/commons-pool/api-2.4.3/index.html"/>
<item name="Javadoc 2.5.0" href="http://commons.apache.org/proper/commons-pool/api-2.5.0/index.html"/>
<item name="Javadoc 2.6.0" href="http://commons.apache.org/proper/commons-pool/api-2.6.0/index.html"/>
<item name="Javadoc 2.6.1" href="http://commons.apache.org/proper/commons-pool/api-2.6.1/index.html"/>
<item name="Javadoc 2.6.2" href="http://commons.apache.org/proper/commons-pool/api-2.6.2/index.html"/>
<item name="Examples" href="/examples.html"/>
<item name="Downloads" href="/download_pool.cgi"/>
<item name="Wiki" href="http://wiki.apache.org/commons/Pool"/>
......
......@@ -36,14 +36,14 @@ limitations under the License.
| (defaults to "-bin", set to "" for pre-maven2 releases) |
| - commons.release.desc (optional) |
| - commons.release.subdir (optional) |
| - commons.release.hash (optional, lowercase, default sha256) |
| - commons.release.hash (optional, lowercase, default sha512) |
| |
| - commons.release.[234].version (conditional) |
| - commons.release.[234].name (conditional) |
| - commons.release.[234].binary.suffix (optional) |
| - commons.release.[234].desc (optional) |
| - commons.release.[234].subdir (optional) |
| - commons.release.[234].hash (optional, lowercase, [sha256])|
| - commons.release.[234].hash (optional, lowercase, [sha512])|
| |
| 3) Example Properties |
| (commons.release.name inherited by parent: |
......@@ -104,7 +104,7 @@ limitations under the License.
It is essential that you
<a href="https://www.apache.org/info/verification.html">verify the integrity</a>
of downloaded files, preferably using the <code>PGP</code> signature (<code>*.asc</code> files);
failing that using the <code>SHA256</code> hash (<code>*.sha256</code> checksum files).
failing that using the <code>SHA512</code> hash (<code>*.sha512</code> checksum files).
</p>
<p>
The <a href="https://www.apache.org/dist/commons/KEYS">KEYS</a>
......@@ -113,32 +113,32 @@ limitations under the License.
</p>
</subsection>
</section>
<section name="Apache Commons Pool 2.6.1 (Java 7)">
<section name="Apache Commons Pool 2.6.2 (Java 7)">
<subsection name="Binaries">
<table>
<tr>
<td><a href="[preferred]/commons/pool/binaries/commons-pool2-2.6.1-bin.tar.gz">commons-pool2-2.6.1-bin.tar.gz</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/binaries/commons-pool2-2.6.1-bin.tar.gz.sha256">sha256</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/binaries/commons-pool2-2.6.1-bin.tar.gz.asc">pgp</a></td>
<td><a href="[preferred]/commons/pool/binaries/commons-pool2-2.6.2-bin.tar.gz">commons-pool2-2.6.2-bin.tar.gz</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/binaries/commons-pool2-2.6.2-bin.tar.gz.sha512">sha512</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/binaries/commons-pool2-2.6.2-bin.tar.gz.asc">pgp</a></td>
</tr>
<tr>
<td><a href="[preferred]/commons/pool/binaries/commons-pool2-2.6.1-bin.zip">commons-pool2-2.6.1-bin.zip</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/binaries/commons-pool2-2.6.1-bin.zip.sha256">sha256</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/binaries/commons-pool2-2.6.1-bin.zip.asc">pgp</a></td>
<td><a href="[preferred]/commons/pool/binaries/commons-pool2-2.6.2-bin.zip">commons-pool2-2.6.2-bin.zip</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/binaries/commons-pool2-2.6.2-bin.zip.sha512">sha512</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/binaries/commons-pool2-2.6.2-bin.zip.asc">pgp</a></td>
</tr>
</table>
</subsection>
<subsection name="Source">
<table>
<tr>
<td><a href="[preferred]/commons/pool/source/commons-pool2-2.6.1-src.tar.gz">commons-pool2-2.6.1-src.tar.gz</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/source/commons-pool2-2.6.1-src.tar.gz.sha256">sha256</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/source/commons-pool2-2.6.1-src.tar.gz.asc">pgp</a></td>
<td><a href="[preferred]/commons/pool/source/commons-pool2-2.6.2-src.tar.gz">commons-pool2-2.6.2-src.tar.gz</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/source/commons-pool2-2.6.2-src.tar.gz.sha512">sha512</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/source/commons-pool2-2.6.2-src.tar.gz.asc">pgp</a></td>
</tr>
<tr>
<td><a href="[preferred]/commons/pool/source/commons-pool2-2.6.1-src.zip">commons-pool2-2.6.1-src.zip</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/source/commons-pool2-2.6.1-src.zip.sha256">sha256</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/source/commons-pool2-2.6.1-src.zip.asc">pgp</a></td>
<td><a href="[preferred]/commons/pool/source/commons-pool2-2.6.2-src.zip">commons-pool2-2.6.2-src.zip</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/source/commons-pool2-2.6.2-src.zip.sha512">sha512</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/source/commons-pool2-2.6.2-src.zip.asc">pgp</a></td>
</tr>
</table>
</subsection>
......@@ -148,12 +148,12 @@ limitations under the License.
<table>
<tr>
<td><a href="[preferred]/commons/pool/binaries/commons-pool2-2.4.3-bin.tar.gz">commons-pool2-2.4.3-bin.tar.gz</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/binaries/commons-pool2-2.4.3-bin.tar.gz.sha256">sha256</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/binaries/commons-pool2-2.4.3-bin.tar.gz.sha512">sha512</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/binaries/commons-pool2-2.4.3-bin.tar.gz.asc">pgp</a></td>
</tr>
<tr>
<td><a href="[preferred]/commons/pool/binaries/commons-pool2-2.4.3-bin.zip">commons-pool2-2.4.3-bin.zip</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/binaries/commons-pool2-2.4.3-bin.zip.sha256">sha256</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/binaries/commons-pool2-2.4.3-bin.zip.sha512">sha512</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/binaries/commons-pool2-2.4.3-bin.zip.asc">pgp</a></td>
</tr>
</table>
......@@ -162,12 +162,12 @@ limitations under the License.
<table>
<tr>
<td><a href="[preferred]/commons/pool/source/commons-pool2-2.4.3-src.tar.gz">commons-pool2-2.4.3-src.tar.gz</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/source/commons-pool2-2.4.3-src.tar.gz.sha256">sha256</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/source/commons-pool2-2.4.3-src.tar.gz.sha512">sha512</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/source/commons-pool2-2.4.3-src.tar.gz.asc">pgp</a></td>
</tr>
<tr>
<td><a href="[preferred]/commons/pool/source/commons-pool2-2.4.3-src.zip">commons-pool2-2.4.3-src.zip</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/source/commons-pool2-2.4.3-src.zip.sha256">sha256</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/source/commons-pool2-2.4.3-src.zip.sha512">sha512</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/source/commons-pool2-2.4.3-src.zip.asc">pgp</a></td>
</tr>
</table>
......@@ -178,12 +178,12 @@ limitations under the License.
<table>
<tr>
<td><a href="[preferred]/commons/pool/binaries/commons-pool-1.6-bin.tar.gz">commons-pool-1.6-bin.tar.gz</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/binaries/commons-pool-1.6-bin.tar.gz.sha256">sha256</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/binaries/commons-pool-1.6-bin.tar.gz.sha512">sha512</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/binaries/commons-pool-1.6-bin.tar.gz.asc">pgp</a></td>
</tr>
<tr>
<td><a href="[preferred]/commons/pool/binaries/commons-pool-1.6-bin.zip">commons-pool-1.6-bin.zip</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/binaries/commons-pool-1.6-bin.zip.sha256">sha256</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/binaries/commons-pool-1.6-bin.zip.sha512">sha512</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/binaries/commons-pool-1.6-bin.zip.asc">pgp</a></td>
</tr>
</table>
......@@ -192,12 +192,12 @@ limitations under the License.
<table>
<tr>
<td><a href="[preferred]/commons/pool/source/commons-pool-1.6-src.tar.gz">commons-pool-1.6-src.tar.gz</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/source/commons-pool-1.6-src.tar.gz.sha256">sha256</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/source/commons-pool-1.6-src.tar.gz.sha512">sha512</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/source/commons-pool-1.6-src.tar.gz.asc">pgp</a></td>
</tr>
<tr>
<td><a href="[preferred]/commons/pool/source/commons-pool-1.6-src.zip">commons-pool-1.6-src.zip</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/source/commons-pool-1.6-src.zip.sha256">sha256</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/source/commons-pool-1.6-src.zip.sha512">sha512</a></td>
<td><a href="https://www.apache.org/dist/commons/pool/source/commons-pool-1.6-src.zip.asc">pgp</a></td>
</tr>
</table>
......
......@@ -34,21 +34,21 @@ import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig;
/**
* On my box with 4 cores this test fails at between 5s and 900s with an average
* of 240s (data from 10 runs of test).
*
*
* It is hard to turn this in a unit test because it can affect the build
* negatively since you need to run it for a while.
*/
public final class ObjectPoolIssue326 {
public static void main(String[] args) {
public static void main(final String[] args) {
try {
new ObjectPoolIssue326().run();
} catch (Exception e) {
} catch (final Exception e) {
e.printStackTrace();
}
}
private void run() throws Exception {
GenericKeyedObjectPoolConfig poolConfig = new GenericKeyedObjectPoolConfig();
final GenericKeyedObjectPoolConfig poolConfig = new GenericKeyedObjectPoolConfig();
poolConfig.setMaxTotal(10);
poolConfig.setMaxTotalPerKey(5);
poolConfig.setMinIdlePerKey(-1);
......@@ -70,13 +70,13 @@ public final class ObjectPoolIssue326 {
poolConfig.setJmxNameBase(null);
poolConfig.setJmxNamePrefix(null);
GenericKeyedObjectPool<Integer, Object> pool = new GenericKeyedObjectPool<>(new ObjectFactory(), poolConfig);
final GenericKeyedObjectPool<Integer, Object> pool = new GenericKeyedObjectPool<>(new ObjectFactory(), poolConfig);
// number of threads to reproduce is finicky. this count seems to be best for my
// 4 core box.
// too many doesn't reproduce it ever, too few doesn't either.
ExecutorService service = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2);
long startTime = System.currentTimeMillis();
final ExecutorService service = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2);
final long startTime = System.currentTimeMillis();
long testIter = 0;
try {
while (true) {
......@@ -84,9 +84,9 @@ public final class ObjectPoolIssue326 {
if (testIter % 1000 == 0) {
System.out.println(testIter);
}
List<Task> tasks = createTasks(pool);
List<Future<Object>> futures = service.invokeAll(tasks);
for (Future<Object> future : futures) {
final List<Task> tasks = createTasks(pool);
final List<Future<Object>> futures = service.invokeAll(tasks);
for (final Future<Object> future : futures) {
future.get();
}
}
......@@ -96,8 +96,8 @@ public final class ObjectPoolIssue326 {
}
}
private List<Task> createTasks(GenericKeyedObjectPool<Integer, Object> pool) {
List<Task> tasks = new ArrayList<>();
private List<Task> createTasks(final GenericKeyedObjectPool<Integer, Object> pool) {
final List<Task> tasks = new ArrayList<>();
for (int i = 0; i < 250; i++) {
tasks.add(new Task(pool, i));
}
......@@ -106,12 +106,12 @@ public final class ObjectPoolIssue326 {
private class ObjectFactory extends BaseKeyedPooledObjectFactory<Integer, Object> {
@Override
public Object create(Integer s) throws Exception {
public Object create(final Integer s) throws Exception {
return new TestObject();
}
@Override
public PooledObject<Object> wrap(Object o) {
public PooledObject<Object> wrap(final Object o) {
return new DefaultPooledObject<>(o);
}
}
......@@ -123,7 +123,7 @@ public final class ObjectPoolIssue326 {
private final GenericKeyedObjectPool<Integer, Object> m_pool;
private final int m_key;
Task(GenericKeyedObjectPool<Integer, Object> pool, int count) {
Task(final GenericKeyedObjectPool<Integer, Object> pool, final int count) {
m_pool = pool;
m_key = count % 20;
}
......@@ -139,7 +139,7 @@ public final class ObjectPoolIssue326 {
busyWait(System.currentTimeMillis() % 4);
m_pool.returnObject(m_key, value);
return "success";
} catch (NoSuchElementException e) {
} catch (final NoSuchElementException e) {
// ignore, we've exhausted the pool
// not sure whether what we do here matters for reproducing
busyWait(System.currentTimeMillis() % 20);
......@@ -147,17 +147,18 @@ public final class ObjectPoolIssue326 {
}
}
private void busyWait(long timeMillis) {
private void busyWait(final long timeMillis) {
// busy waiting intentionally as a simple thread.sleep fails to reproduce
long endTime = System.currentTimeMillis() + timeMillis;
while (System.currentTimeMillis() < endTime)
;
final long endTime = System.currentTimeMillis() + timeMillis;
while (System.currentTimeMillis() < endTime) {
// empty
}
}
}
}
/*
*
*
* Example stack trace: java.util.concurrent.ExecutionException:
* java.lang.NullPointerException at
* java.util.concurrent.FutureTask.report(FutureTask.java:122) at
......@@ -179,5 +180,5 @@ public final class ObjectPoolIssue326 {
* 1142) at
* java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:
* 617) at java.lang.Thread.run(Thread.java:745)
*
*
*/
......@@ -54,7 +54,7 @@ public class TestAbandonedObjectPool {
abandonedConfig.setRemoveAbandonedTimeout(1);
pool = new GenericObjectPool<>(
new SimpleFactory(),
new GenericObjectPoolConfig(),
new GenericObjectPoolConfig<PooledTestObject>(),
abandonedConfig);
}
......@@ -148,7 +148,7 @@ public class TestAbandonedObjectPool {
pool.close(); // Unregister pool created by setup
pool = new GenericObjectPool<>(
new SimpleFactory(200, 0),
new GenericObjectPoolConfig(), abandonedConfig);
new GenericObjectPoolConfig<PooledTestObject>(), abandonedConfig);
final int n = 10;
pool.setMaxTotal(n);
pool.setBlockWhenExhausted(false);
......@@ -186,7 +186,7 @@ public class TestAbandonedObjectPool {
pool = new GenericObjectPool<>(
// destroys take 200 ms
new SimpleFactory(200, 0),
new GenericObjectPoolConfig(), abandonedConfig);
new GenericObjectPoolConfig<PooledTestObject>(), abandonedConfig);
final int n = 10;
pool.setMaxTotal(n);
pool.setBlockWhenExhausted(false);
......@@ -216,8 +216,8 @@ public class TestAbandonedObjectPool {
pool.close(); // Unregister pool created by setup
pool = new GenericObjectPool<>(
// validate takes 1 second
new SimpleFactory(0, 1000),
new GenericObjectPoolConfig(), abandonedConfig);
new SimpleFactory(0, 1000),
new GenericObjectPoolConfig<PooledTestObject>(), abandonedConfig);
final int n = 10;
pool.setMaxTotal(n);
pool.setBlockWhenExhausted(false);
......
......@@ -113,7 +113,7 @@ public class TestDefaultPooledObjectInfo {
abandonedConfig.setRemoveAbandonedTimeout(1);
abandonedConfig.setLogAbandoned(true);
try (final GenericObjectPool<String> pool = new GenericObjectPool<>(new SimpleFactory(),
new GenericObjectPoolConfig(), abandonedConfig)) {
new GenericObjectPoolConfig<String>(), abandonedConfig)) {
pool.borrowObject();
// pool.returnObject(s1); // Object not returned, causes abandoned object created exception
......
......@@ -422,7 +422,7 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool {
*/
@Test
public void testContructorEvictionConfig() throws Exception {
final GenericKeyedObjectPoolConfig config = new GenericKeyedObjectPoolConfig();
final GenericKeyedObjectPoolConfig<String> config = new GenericKeyedObjectPoolConfig<>();
config.setTimeBetweenEvictionRunsMillis(500);
config.setMinEvictableIdleTimeMillis(50);
config.setNumTestsPerEvictionRun(5);
......@@ -433,11 +433,13 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool {
try {
Thread.sleep(100);
} catch (final InterruptedException e) {
// ignore
}
assertEquals(5, p.getNumIdle("one"));
try {
Thread.sleep(500);
} catch (final InterruptedException e) {
// ignore
}
assertEquals(0, p.getNumIdle("one"));
}
......@@ -1156,7 +1158,7 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool {
assertEquals(Boolean.valueOf(BaseObjectPoolConfig.DEFAULT_LIFO), Boolean.valueOf(objPool.getLifo()));
}
final GenericKeyedObjectPoolConfig config = new GenericKeyedObjectPoolConfig();
final GenericKeyedObjectPoolConfig<Object> config = new GenericKeyedObjectPoolConfig<>();
config.setLifo(lifo);
config.setMaxTotalPerKey(maxTotalPerKey);
config.setMaxIdlePerKey(maxIdle);
......@@ -1190,9 +1192,11 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool {
@Test(expected=IllegalArgumentException.class)
public void testConstructorNullFactory() {
// add dummy assert (won't be invoked because of IAE) to avoid "unused" warning
assertNotNull(new GenericKeyedObjectPool<String,String>(null));
// TODO this currently causes tearDown to report an error
// Looks like GKOP needs to call close() on its parent before throwing IAE
try (GenericKeyedObjectPool<String, String> object = new GenericKeyedObjectPool<>(null)) {
assertNotNull(object);
// TODO this currently causes tearDown to report an error
// Looks like GKOP needs to call close() on its parent before throwing IAE
}
}
@Test(timeout=60000)
......@@ -1563,7 +1567,7 @@ public class TestGenericKeyedObjectPool extends TestKeyedObjectPool {