commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1021570 - in /commons/proper/pool/trunk/src: java/org/apache/commons/pool/ test/org/apache/commons/pool/impl/
Date Tue, 12 Oct 2010 01:24:33 GMT
Author: sebb
Date: Tue Oct 12 01:24:33 2010
New Revision: 1021570

URL: http://svn.apache.org/viewvc?rev=1021570&view=rev
Log:
Missing annotations and unnecessary casts

Modified:
    commons/proper/pool/trunk/src/java/org/apache/commons/pool/BaseObjectPool.java
    commons/proper/pool/trunk/src/java/org/apache/commons/pool/KeyedObjectPool.java
    commons/proper/pool/trunk/src/java/org/apache/commons/pool/ObjectPool.java
    commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestGenericObjectPool.java
    commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestSoftRefOutOfMemory.java
    commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestStackKeyedObjectPool.java
    commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestStackObjectPool.java

Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool/BaseObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool/BaseObjectPool.java?rev=1021570&r1=1021569&r2=1021570&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool/BaseObjectPool.java (original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool/BaseObjectPool.java Tue Oct
12 01:24:33 2010
@@ -115,6 +115,7 @@ public abstract class BaseObjectPool<T> 
      * @throws IllegalStateException
      * @deprecated to be removed in pool 2.0
      */
+    @Deprecated
     public void setFactory(PoolableObjectFactory<T> factory) throws IllegalStateException,
UnsupportedOperationException {
         throw new UnsupportedOperationException();
     }

Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool/KeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool/KeyedObjectPool.java?rev=1021570&r1=1021569&r2=1021570&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool/KeyedObjectPool.java (original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool/KeyedObjectPool.java Tue Oct
12 01:24:33 2010
@@ -225,5 +225,6 @@ public interface KeyedObjectPool<K,V> {
      * @throws UnsupportedOperationException when this implementation doesn't support the
operation
      * @deprecated to be removed in pool 2.0
      */
+    @Deprecated
     void setFactory(KeyedPoolableObjectFactory<K,V> factory) throws IllegalStateException,
UnsupportedOperationException;
 }

Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool/ObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool/ObjectPool.java?rev=1021570&r1=1021569&r2=1021570&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool/ObjectPool.java (original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool/ObjectPool.java Tue Oct 12
01:24:33 2010
@@ -186,5 +186,6 @@ public interface ObjectPool<T> {
      * @throws UnsupportedOperationException if this implementation does not support the
operation
      * @deprecated to be removed in pool 2.0
      */
+    @Deprecated
     void setFactory(PoolableObjectFactory<T> factory) throws IllegalStateException,
UnsupportedOperationException;
 }

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestGenericObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestGenericObjectPool.java?rev=1021570&r1=1021569&r2=1021570&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestGenericObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestGenericObjectPool.java
Tue Oct 12 01:24:33 2010
@@ -39,6 +39,7 @@ public class TestGenericObjectPool exten
         super(testName);
     }
 
+    @Override
     protected ObjectPool<Object> makeEmptyPool(int mincap) {
        GenericObjectPool<Object> pool = new GenericObjectPool<Object>(new SimpleFactory());
        pool.setMaxActive(mincap);
@@ -46,19 +47,23 @@ public class TestGenericObjectPool exten
        return pool;
     }
 
+    @Override
     protected ObjectPool<Object> makeEmptyPool(final PoolableObjectFactory<Object>
factory) {
         return new GenericObjectPool<Object>(factory);
     }
 
+    @Override
     protected Object getNthObject(int n) {
         return String.valueOf(n);
     }
 
+    @Override
     public void setUp() throws Exception {
         super.setUp();
         pool = new GenericObjectPool<Object>(new SimpleFactory());
     }
 
+    @Override
     public void tearDown() throws Exception {
         super.tearDown();
         pool.clear();
@@ -991,6 +996,7 @@ public class TestGenericObjectPool exten
             public TimeTest() {
                 createTime = System.currentTimeMillis();
             }
+            @Override
             public TimeTest makeObject() throws Exception {
                 return new TimeTest();
             }
@@ -1012,7 +1018,7 @@ public class TestGenericObjectPool exten
         Long[] creationTime = new Long[5] ;
         for(int i=0;i<5;i++) {
             active[i] = pool.borrowObject();
-            creationTime[i] = new Long(((TimeTest)active[i]).getCreateTime());
+            creationTime[i] = new Long(active[i].getCreateTime());
         }
         
         for(int i=0;i<5;i++) {
@@ -1486,10 +1492,12 @@ public class TestGenericObjectPool exten
             }
         }
     }
+    @Override
     protected boolean isLifo() {
         return true;
     }
 
+    @Override
     protected boolean isFifo() {
         return false;
     }
@@ -1608,6 +1616,7 @@ public class TestGenericObjectPool exten
             _thrown = null;
         }
 
+        @Override
         public void run() {
             try {
                 preborrow = System.currentTimeMillis();

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestSoftRefOutOfMemory.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestSoftRefOutOfMemory.java?rev=1021570&r1=1021569&r2=1021570&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestSoftRefOutOfMemory.java
(original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestSoftRefOutOfMemory.java
Tue Oct 12 01:24:33 2010
@@ -116,7 +116,7 @@ public class TestSoftRefOutOfMemory exte
         pool = new SoftReferenceObjectPool<String>(new LargePoolableObjectFactory(1000000));
 
         String obj = pool.borrowObject();
-        assertTrue(((String)obj).startsWith("1."));
+        assertTrue(obj.startsWith("1."));
         pool.returnObject(obj);
         obj = null;
 
@@ -136,7 +136,7 @@ public class TestSoftRefOutOfMemory exte
         System.gc();
 
         obj = pool.borrowObject();
-        assertTrue(((String)obj).startsWith("2."));
+        assertTrue((obj).startsWith("2."));
         pool.returnObject(obj);
         obj = null;
 

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestStackKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestStackKeyedObjectPool.java?rev=1021570&r1=1021569&r2=1021570&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestStackKeyedObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestStackKeyedObjectPool.java
Tue Oct 12 01:24:33 2010
@@ -34,25 +34,30 @@ public class TestStackKeyedObjectPool ex
         super(testName);
     }
 
+    @Override
     protected KeyedObjectPool<Object,Object> makeEmptyPool(int mincapacity) {
         StackKeyedObjectPool<Object,Object> pool = new StackKeyedObjectPool<Object,Object>(new
SimpleFactory(),mincapacity);
         return pool;
     }
 
+    @Override
     protected KeyedObjectPool<Object,Object> makeEmptyPool(KeyedPoolableObjectFactory<Object,Object>
factory) {
         return new StackKeyedObjectPool<Object,Object>(factory);
     }
 
+    @Override
     protected Object getNthObject(Object key, int n) {
         return String.valueOf(key) + String.valueOf(n);
     }
 
+    @Override
     protected Object makeKey(int n) {
         return String.valueOf(n);
     }
 
     private StackKeyedObjectPool<String,String> pool = null;
 
+    @Override
     public void setUp() throws Exception {
         super.setUp();
         pool = new StackKeyedObjectPool<String,String>(
@@ -68,6 +73,7 @@ public class TestStackKeyedObjectPool ex
     }
 
 
+    @Override
     public void tearDown() throws Exception {
         super.tearDown();
         pool = null;
@@ -138,7 +144,7 @@ public class TestStackKeyedObjectPool ex
             Integer[] borrowed = new Integer[10];
             BitSet found = new BitSet();
             for(int i=0;i<10;i++) {
-                borrowed[i] = (Integer)(pool.borrowObject("X"));
+                borrowed[i] = (pool.borrowObject("X"));
                 assertNotNull(borrowed);
                 assertTrue(!found.get(borrowed[i].intValue()));
                 found.set(borrowed[i].intValue());
@@ -180,6 +186,7 @@ public class TestStackKeyedObjectPool ex
         }
     }
 
+    @Override
     public void testToString() throws Exception {
         StackKeyedObjectPool<Object,Object> pool = new StackKeyedObjectPool<Object,Object>(new
SimpleFactory());
         assertNotNull(pool.toString());
@@ -317,10 +324,12 @@ public class TestStackKeyedObjectPool ex
         public void passivateObject(Object key, Object obj) { }
     }
 
+    @Override
     protected boolean isLifo() {
         return true;
     }
 
+    @Override
     protected boolean isFifo() {
         return false;
     }

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestStackObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestStackObjectPool.java?rev=1021570&r1=1021569&r2=1021570&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestStackObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestStackObjectPool.java
Tue Oct 12 01:24:33 2010
@@ -37,14 +37,17 @@ public class TestStackObjectPool extends
         super(testName);
     }
 
+    @Override
     protected ObjectPool<Object> makeEmptyPool(int mincap) {
         return new StackObjectPool<Object>(new SimpleFactory());
     }
 
+    @Override
     protected ObjectPool<Object> makeEmptyPool(final PoolableObjectFactory<Object>
factory) {
         return new StackObjectPool<Object>(factory);
     }
 
+    @Override
     protected Object getNthObject(int n) {
         return String.valueOf(n);
     }
@@ -106,6 +109,7 @@ public class TestStackObjectPool extends
     /**
      * @deprecated - to be removed in pool 2.0
      */
+    @Override
     public void testSetFactory() throws Exception {
         ObjectPool<Object> pool = new StackObjectPool<Object>();
         try {
@@ -174,7 +178,7 @@ public class TestStackObjectPool extends
                 try {
                     k++;
                     object = pool.borrowObject();
-                    if (((Integer) object).intValue() % 2 == 0) {
+                    if (object.intValue() % 2 == 0) {
                         fail("Expecting NoSuchElementException");
                     } else {
                         obj[i] = object; 
@@ -274,10 +278,10 @@ public class TestStackObjectPool extends
         ObjectPool<Integer> pool = new StackObjectPool<Integer>(factory, 3);
 
         // borrow more objects than the pool can hold
-        Integer i0 = (Integer)pool.borrowObject();
-        Integer i1 = (Integer)pool.borrowObject();
-        Integer i2 = (Integer)pool.borrowObject();
-        Integer i3 = (Integer)pool.borrowObject();
+        Integer i0 = pool.borrowObject();
+        Integer i1 = pool.borrowObject();
+        Integer i2 = pool.borrowObject();
+        Integer i3 = pool.borrowObject();
 
         // tests
         // return as many as the pool will hold.
@@ -293,7 +297,7 @@ public class TestStackObjectPool extends
         assertEquals("One object should have been destroyed.", 1, factory.getDestroyed().size());
 
         // check to see what object was destroyed
-        Integer d = (Integer)factory.getDestroyed().get(0);
+        Integer d = factory.getDestroyed().get(0);
         assertEquals("Destoryed object should be the stalest object.", i0, d);
     }
     
@@ -460,13 +464,14 @@ public class TestStackObjectPool extends
      * Verifies close contract - idle instances are destroyed, returning instances
      * are destroyed, add/borrowObject throw IllegalStateException.
      */
+    @Override
     public void testClose() throws Exception {
         SelectiveFactory factory = new SelectiveFactory();
         ObjectPool<Integer> pool = new StackObjectPool<Integer>(factory);
         pool.addObject(); // 0
         pool.addObject(); // 1
         pool.addObject(); // 2
-        Integer two = (Integer) pool.borrowObject();
+        Integer two = pool.borrowObject();
         assertEquals(2, two.intValue());
         pool.close();
         assertEquals(0, pool.getNumIdle());
@@ -529,20 +534,20 @@ public class TestStackObjectPool extends
         }
         public void destroyObject(Integer obj) {
             if (throwOnDestroy) {
-                final Integer integer = (Integer)obj;
+                final Integer integer = obj;
                 throw new IntegerFactoryException("destroyObject", integer.intValue());
             }
             destroyed.add(obj);
         }
         public boolean validateObject(Integer obj) {
             if (throwOnValidate) {
-                final Integer integer = (Integer)obj;
+                final Integer integer = obj;
                 throw new IntegerFactoryException("validateObject", integer.intValue());
             }
             if (validateSelectively) {
                 // only odd objects are valid
                 if(obj instanceof Integer) {
-                    return ((((Integer)obj).intValue() % 2) == 1);
+                    return (((obj).intValue() % 2) == 1);
                 } else {
                     return false;
                 }
@@ -551,17 +556,17 @@ public class TestStackObjectPool extends
         }
         public void activateObject(Integer obj) {
             if (throwOnActivate) {
-                final Integer integer = (Integer)obj;
+                final Integer integer = obj;
                 throw new IntegerFactoryException("activateObject", integer.intValue());
             }
         }
         public void passivateObject(Integer obj) { 
             if (throwOnPassivate) {
-                final Integer integer = (Integer)obj;
+                final Integer integer = obj;
                 throw new IntegerFactoryException("passivateObject", integer.intValue());
             }
             if (passivateSelectively) {
-                final Integer integer = (Integer)obj;
+                final Integer integer = obj;
                 if (integer.intValue() % 3 == 0) {
                     throw new IntegerFactoryException("passivateObject", integer.intValue());
                 }
@@ -615,10 +620,12 @@ public class TestStackObjectPool extends
         }
     }
 
+    @Override
     protected boolean isLifo() {
         return true;
     }
 
+    @Override
     protected boolean isFifo() {
         return false;
     }



Mime
View raw message