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 2013/10/11 00:42:52 UTC

svn commit: r1531145 - in /commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2: TestKeyedObjectPool.java TestPoolUtils.java Waiter.java impl/TestAbandonedObjectPool.java performance/PerformanceTest.java

Author: markt
Date: Thu Oct 10 22:42:51 2013
New Revision: 1531145

URL: http://svn.apache.org/r1531145
Log:
Fix various Javadoc and other IDE warnings

Modified:
    commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestKeyedObjectPool.java
    commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestPoolUtils.java
    commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/Waiter.java
    commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestAbandonedObjectPool.java
    commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/performance/PerformanceTest.java

Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestKeyedObjectPool.java?rev=1531145&r1=1531144&r2=1531145&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestKeyedObjectPool.java (original)
+++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestKeyedObjectPool.java Thu Oct 10 22:42:51 2013
@@ -739,7 +739,7 @@ public abstract class TestKeyedObjectPoo
         }
 
         @Override
-        public PooledObject makeObject(final Object key) throws Exception {
+        public PooledObject<Object> makeObject(final Object key) throws Exception {
             final MethodCall call = new MethodCall("makeObject", key);
             methodCalls.add(call);
             int count = this.count++;
@@ -748,11 +748,11 @@ public abstract class TestKeyedObjectPoo
             }
             final Integer obj = new Integer(count);
             call.setReturned(obj);
-            return new DefaultPooledObject(obj);
+            return new DefaultPooledObject<Object>(obj);
         }
 
         @Override
-        public void activateObject(final Object key, final PooledObject obj) throws Exception {
+        public void activateObject(final Object key, final PooledObject<Object> obj) throws Exception {
             methodCalls.add(new MethodCall("activateObject", key, obj.getObject()));
             if (activateObjectFail) {
                 throw new PrivateException("activateObject");
@@ -760,7 +760,7 @@ public abstract class TestKeyedObjectPoo
         }
 
         @Override
-        public boolean validateObject(final Object key, final PooledObject obj) {
+        public boolean validateObject(final Object key, final PooledObject<Object> obj) {
             final MethodCall call = new MethodCall("validateObject", key, obj.getObject());
             methodCalls.add(call);
             if (validateObjectFail) {
@@ -772,7 +772,7 @@ public abstract class TestKeyedObjectPoo
         }
 
         @Override
-        public void passivateObject(final Object key, final PooledObject obj) throws Exception {
+        public void passivateObject(final Object key, final PooledObject<Object> obj) throws Exception {
             methodCalls.add(new MethodCall("passivateObject", key, obj.getObject()));
             if (passivateObjectFail) {
                 throw new PrivateException("passivateObject");
@@ -780,7 +780,7 @@ public abstract class TestKeyedObjectPoo
         }
 
         @Override
-        public void destroyObject(final Object key, final PooledObject obj) throws Exception {
+        public void destroyObject(final Object key, final PooledObject<Object> obj) throws Exception {
             methodCalls.add(new MethodCall("destroyObject", key, obj.getObject()));
             if (destroyObjectFail) {
                 throw new PrivateException("destroyObject");

Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestPoolUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestPoolUtils.java?rev=1531145&r1=1531144&r2=1531145&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestPoolUtils.java (original)
+++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestPoolUtils.java Thu Oct 10 22:42:51 2013
@@ -39,7 +39,7 @@ import junit.framework.AssertionFailedEr
 import org.apache.commons.pool2.impl.DefaultPooledObject;
 import org.apache.commons.pool2.impl.GenericKeyedObjectPool;
 import org.apache.commons.pool2.impl.GenericObjectPool;
-import org.apache.commons.pool2.impl.PoolImplUtils;
+
 import org.junit.Test;
 
 /**
@@ -761,6 +761,7 @@ public class TestPoolUtils {
     }
 
     private static <T> T createProxy(final Class<T> clazz, final InvocationHandler handler) {
+        @SuppressWarnings("unchecked")
         T ret = (T) Proxy.newProxyInstance(
                 clazz.getClassLoader(), new Class[] { clazz }, handler);
         return ret;

Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/Waiter.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/Waiter.java?rev=1531145&r1=1531144&r2=1531145&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/Waiter.java (original)
+++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/Waiter.java Thu Oct 10 22:42:51 2013
@@ -5,9 +5,9 @@
  * 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.
@@ -21,7 +21,7 @@ import java.util.concurrent.atomic.Atomi
 
 /**
  * <p>Object created by {@link WaiterFactory}. Maintains active / valid state,
- * last passivated and idle times.  Waits with configurable latency when 
+ * last passivated and idle times.  Waits with configurable latency when
  * {@link #doWait()} method is called.</p>
  *
  * <p>This class is *not* threadsafe.</p>
@@ -34,7 +34,7 @@ public class Waiter {
     private long lastPassivated = 0;
     private long lastIdleTimeMs = 0;
     private int id = instanceCount.getAndIncrement();
-    
+
     public Waiter(boolean active, boolean valid, long latency) {
         this.active = active;
         this.valid = valid;
@@ -55,7 +55,7 @@ public class Waiter {
 
     /**
      * Whether or not the instance is active.
-     * 
+     *
      * @return true if the last lifecycle event for this instance was activation.
      */
     public boolean isActive() {
@@ -65,17 +65,17 @@ public class Waiter {
     /**
      * <p>Sets the active state and updates {@link #getLastIdleTimeMs() lastIdleTime}
      * or {@link #getLastPassivated() lastPassivated} as appropriate.</p>
-     * 
+     *
      * <p>If the active state is changing from inactive to active, lastIdleTime
      * is updated with the current time minus lastPassivated.  If the state is
      * changing from active to inactive, lastPassivated is updated with the
      * current time.</p>
-     * 
-     * <p>{@link WaiterFactory#activateObject(Object)} and
-     * {@link WaiterFactory#passivateObject(Object)} invoke this method on their
-     * actual parameter, passing <code>true</code> and <code>false</code>,
+     *
+     * <p>{@link WaiterFactory#activateObject(PooledObject)} and
+     * {@link WaiterFactory#passivateObject(PooledObject)} invoke this method on
+     * their actual parameter, passing <code>true</code> and <code>false</code>,
      * respectively.</p>
-     * 
+     *
      * @param active new active state
      */
     public void setActive(boolean active) {
@@ -107,37 +107,37 @@ public class Waiter {
     public void setValid(boolean valid) {
         this.valid = valid;
     }
-    
+
     /**
      * <p>Returns the system time of this instance's last passivation.</p>
-     * 
+     *
      * <p>When an instance is created, this field is initialized to the system time.</p>
-     * 
+     *
      * @return time of last passivation
      */
     public long getLastPassivated() {
         return lastPassivated;
     }
-    
+
     /**
      * <p>Returns the last idle time for this instance in ms.</p>
-     * 
+     *
      * <p>When an instance is created, and each subsequent time it is passivated,
      * the {@link #getLastPassivated() lastPassivated} property is updated with the
      * current time.  When the next activation occurs, <code>lastIdleTime</code> is
      * updated with the elapsed time since passivation.<p>
-     * 
+     *
      * @return last idle time
      */
     public long getLastIdleTimeMs() {
         return lastIdleTimeMs;
     }
-    
+
     @Override
     public int hashCode() {
-        return id;     
+        return id;
     }
-    
+
     @Override
     public boolean equals(Object obj) {
         if (!(obj instanceof Waiter)) {
@@ -145,7 +145,7 @@ public class Waiter {
         }
         return obj.hashCode() == id;
     }
-    
+
     @Override
     public String toString() {
         StringBuilder buff = new StringBuilder();
@@ -156,5 +156,5 @@ public class Waiter {
         buff.append("lastIdleTimeMs = " + lastIdleTimeMs + "\n");
         buff.append("latency = " + latency + "\n");
         return buff.toString();
-    } 
+    }
 }

Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestAbandonedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestAbandonedObjectPool.java?rev=1531145&r1=1531144&r2=1531145&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestAbandonedObjectPool.java (original)
+++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestAbandonedObjectPool.java Thu Oct 10 22:42:51 2013
@@ -149,6 +149,9 @@ public class TestAbandonedObjectPool ext
         for (int i = 0; i < n - 2; i++) {
             obj = pool.borrowObject();
         }
+        if (obj == null) {
+            throw new NullPointerException("Unable to borrow object from pool");
+        }
         final int deadMansHash = obj.hashCode();
         ConcurrentReturner returner = new ConcurrentReturner(obj);
         Thread.sleep(2000);  // abandon checked out instances

Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/performance/PerformanceTest.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/performance/PerformanceTest.java?rev=1531145&r1=1531144&r2=1531145&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/performance/PerformanceTest.java (original)
+++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/performance/PerformanceTest.java Thu Oct 10 22:42:51 2013
@@ -26,7 +26,6 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
 
 import org.apache.commons.pool2.impl.GenericObjectPool;
-import org.apache.commons.pool2.impl.PoolImplUtils;
 
 /**
  * Multi-thread performance test