You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ma...@apache.org on 2011/05/11 16:54:47 UTC
svn commit: r1101907 - in /commons/proper/pool/trunk/src:
changes/changes.xml java/org/apache/commons/pool2/impl/StackObjectPool.java
test/org/apache/commons/pool2/impl/TestStackObjectPool.java
Author: markt
Date: Wed May 11 14:54:46 2011
New Revision: 1101907
URL: http://svn.apache.org/viewvc?rev=1101907&view=rev
Log:
Remove deprecated code
Modified:
commons/proper/pool/trunk/src/changes/changes.xml
commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackObjectPool.java
commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackObjectPool.java
Modified: commons/proper/pool/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/changes/changes.xml?rev=1101907&r1=1101906&r2=1101907&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/changes/changes.xml (original)
+++ commons/proper/pool/trunk/src/changes/changes.xml Wed May 11 14:54:46 2011
@@ -37,7 +37,8 @@
the appropriate getters.
</action>
<action dev="markt" type="update">
- Code clean-up for Java 1.5 (@Override annotations).
+ Code clean-up. Add missing @Override annotations and remove deprecated
+ code.
</action>
</release>
<release version="1.5.6" date="2011-04-03" description="This is a patch release, including bugfixes only.">
Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackObjectPool.java?rev=1101907&r1=1101906&r2=1101907&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackObjectPool.java (original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackObjectPool.java Wed May 11 14:54:46 2011
@@ -46,52 +46,7 @@ import org.apache.commons.pool2.Poolable
* @version $Revision$ $Date$
* @since Pool 1.0
*/
-public class StackObjectPool<T> extends BaseObjectPool<T> implements ObjectPool<T> {
- /**
- * Create a new pool using no factory. Clients must first
- * {@link #setFactory(PoolableObjectFactory) set the factory} or
- * else this pool will not behave correctly. Clients may first populate the pool
- * using {@link #returnObject(java.lang.Object)} before they can be {@link #borrowObject borrowed}
- * but this usage is <strong>discouraged</strong>.
- *
- * @see #StackObjectPool(PoolableObjectFactory)
- * @deprecated to be removed in pool 2.0 - use {@link #StackObjectPool(PoolableObjectFactory)}
- */
- public StackObjectPool() {
- this((PoolableObjectFactory<T>)null,DEFAULT_MAX_SLEEPING,DEFAULT_INIT_SLEEPING_CAPACITY);
- }
-
- /**
- * Create a new pool using no factory.
- * Clients must first {@link #setFactory(PoolableObjectFactory) set the factory} or
- * else this pool will not behave correctly. Clients may first populate the pool
- * using {@link #returnObject(java.lang.Object)} before they can be {@link #borrowObject borrowed}
- * but this usage is <strong>discouraged</strong>.
- *
- * @param maxIdle cap on the number of "sleeping" instances in the pool
- * @see #StackObjectPool(PoolableObjectFactory, int)
- * @deprecated to be removed in pool 2.0 - use {@link #StackObjectPool(PoolableObjectFactory, int)}
- */
- public StackObjectPool(int maxIdle) {
- this((PoolableObjectFactory<T>)null,maxIdle,DEFAULT_INIT_SLEEPING_CAPACITY);
- }
-
- /**
- * Create a new pool using no factory.
- * Clients must first {@link #setFactory(PoolableObjectFactory) set the factory} or
- * else this pool will not behave correctly. Clients may first populate the pool
- * using {@link #returnObject(java.lang.Object)} before they can be {@link #borrowObject borrowed}
- * but this usage is <strong>discouraged</strong>.
- *
- * @param maxIdle cap on the number of "sleeping" instances in the pool
- * @param initIdleCapacity initial size of the pool (this specifies the size of the container,
- * it does not cause the pool to be pre-populated.)
- * @see #StackObjectPool(PoolableObjectFactory, int, int)
- * @deprecated to be removed in pool 2.0 - use {@link #StackObjectPool(PoolableObjectFactory, int, int)}
- */
- public StackObjectPool(int maxIdle, int initIdleCapacity) {
- this((PoolableObjectFactory<T>)null,maxIdle,initIdleCapacity);
- }
+public class StackObjectPool<T> extends BaseObjectPool<T> {
/**
* Create a new <tt>StackObjectPool</tt> using the specified <i>factory</i> to create new instances.
Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackObjectPool.java?rev=1101907&r1=1101906&r2=1101907&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackObjectPool.java (original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackObjectPool.java Wed May 11 14:54:46 2011
@@ -23,14 +23,12 @@ import static junit.framework.Assert.ass
import static junit.framework.Assert.fail;
import java.util.ArrayList;
-import java.util.BitSet;
import java.util.List;
import java.util.NoSuchElementException;
import org.apache.commons.pool2.ObjectPool;
import org.apache.commons.pool2.PoolableObjectFactory;
import org.apache.commons.pool2.TestBaseObjectPool;
-import org.junit.Ignore;
import org.junit.Test;
/**
@@ -73,111 +71,6 @@ public class TestStackObjectPool extends
}
/**
- * @deprecated - to be removed in pool 2.0
- */
- @Test
- @Ignore
- @Deprecated
- public void testPoolWithNullFactory() throws Exception {
- ObjectPool<Integer> pool = new StackObjectPool<Integer>(10);
- for(int i=0;i<10;i++) {
- pool.returnObject(new Integer(i));
- }
- for(int j=0;j<3;j++) {
- Integer[] borrowed = new Integer[10];
- BitSet found = new BitSet();
- for(int i=0;i<10;i++) {
- borrowed[i] = pool.borrowObject();
- assertNotNull(borrowed);
- assertTrue(!found.get(borrowed[i].intValue()));
- found.set(borrowed[i].intValue());
- }
- for(int i=0;i<10;i++) {
- pool.returnObject(borrowed[i]);
- }
- }
- pool.invalidateObject(pool.borrowObject());
- pool.invalidateObject(pool.borrowObject());
- pool.clear();
- }
-
- /**
- * @deprecated - to be removed in pool 2.0
- */
- public void testBorrowFromEmptyPoolWithNullFactory() throws Exception {
- ObjectPool<Object> pool = new StackObjectPool<Object>();
- try {
- pool.borrowObject();
- fail("Expected NoSuchElementException");
- } catch(NoSuchElementException e) {
- // expected
- }
- }
-
- /**
- * @deprecated - to be removed in pool 2.0
- */
- @Override
- @Test
- @Ignore
- @Deprecated
- public void testSetFactory() throws Exception {
- ObjectPool<Object> pool = new StackObjectPool<Object>();
- try {
- pool.borrowObject();
- fail("Expected NoSuchElementException");
- } catch(NoSuchElementException e) {
- // expected
- }
- pool.setFactory(new SimpleFactory());
- Object obj = pool.borrowObject();
- assertNotNull(obj);
- pool.returnObject(obj);
- }
-
- /**
- * @deprecated - to be removed in pool 2.0
- */
- @Test
- @Ignore
- @Deprecated
- public void testCantResetFactoryWithActiveObjects() throws Exception {
- ObjectPool<Object> pool = new StackObjectPool<Object>();
- pool.setFactory(new SimpleFactory());
- Object obj = pool.borrowObject();
- assertNotNull(obj);
-
- try {
- pool.setFactory(new SimpleFactory());
- fail("Expected IllegalStateException");
- } catch(IllegalStateException e) {
- // expected
- }
- }
-
- /**
- * @deprecated - to be removed in pool 2.0
- */
- @Test
- @Ignore
- @Deprecated
- public void testCanResetFactoryWithoutActiveObjects() throws Exception {
- ObjectPool<Object> pool = new StackObjectPool<Object>();
- {
- pool.setFactory(new SimpleFactory());
- Object obj = pool.borrowObject();
- assertNotNull(obj);
- pool.returnObject(obj);
- }
- {
- pool.setFactory(new SimpleFactory());
- Object obj = pool.borrowObject();
- assertNotNull(obj);
- pool.returnObject(obj);
- }
- }
-
- /**
* Verifies that validation failures when borrowing newly created instances
* from the pool result in NoSuchElementExceptions and passivation failures
* result in instances not being returned to the pool.
@@ -253,18 +146,6 @@ public class TestStackObjectPool extends
@Test
public void testVariousConstructors() throws Exception {
{
- StackObjectPool<Object> pool = new StackObjectPool<Object>();
- assertNotNull(pool);
- }
- {
- StackObjectPool<Object> pool = new StackObjectPool<Object>(10);
- assertNotNull(pool);
- }
- {
- StackObjectPool<Object> pool = new StackObjectPool<Object>(10,5);
- assertNotNull(pool);
- }
- {
StackObjectPool<Object> pool = new StackObjectPool<Object>(null);
assertNotNull(pool);
}
@@ -635,6 +516,7 @@ public class TestStackObjectPool extends
}
static class IntegerFactoryException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
private String type;
private int value;
public IntegerFactoryException(String type, int value) {