commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1701089 - in /commons/proper/pool/trunk/src: main/java/org/apache/commons/pool2/impl/ test/java/org/apache/commons/pool2/ test/java/org/apache/commons/pool2/impl/
Date Thu, 03 Sep 2015 18:03:36 GMT
Author: ggregory
Date: Thu Sep  3 18:03:35 2015
New Revision: 1701089

URL: http://svn.apache.org/r1701089
Log:
Statement unnecessarily nested within else clause.

Modified:
    commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/DefaultPooledObject.java
    commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/DefaultPooledObjectInfo.java
    commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
    commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericObjectPool.java
    commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PoolImplUtils.java
    commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/SoftReferenceObjectPool.java
    commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/WaiterFactory.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/impl/TestGenericKeyedObjectPool.java
    commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java
    commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestSoftRefOutOfMemory.java

Modified: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/DefaultPooledObject.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/DefaultPooledObject.java?rev=1701089&r1=1701088&r2=1701089&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/DefaultPooledObject.java
(original)
+++ commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/DefaultPooledObject.java
Thu Sep  3 18:03:35 2015
@@ -78,9 +78,8 @@ public class DefaultPooledObject<T> impl
 
         if (rTime > bTime) {
             return rTime - bTime;
-        } else {
-            return System.currentTimeMillis() - bTime;
         }
+        return System.currentTimeMillis() - bTime;
     }
 
     @Override
@@ -124,9 +123,8 @@ public class DefaultPooledObject<T> impl
     public long getLastUsedTime() {
         if (object instanceof TrackedUse) {
             return Math.max(((TrackedUse) object).getLastUsed(), lastUseTime);
-        } else {
-            return lastUseTime;
         }
+        return lastUseTime;
     }
 
     @Override

Modified: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/DefaultPooledObjectInfo.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/DefaultPooledObjectInfo.java?rev=1701089&r1=1701088&r2=1701089&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/DefaultPooledObjectInfo.java
(original)
+++ commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/DefaultPooledObjectInfo.java
Thu Sep  3 18:03:35 2015
@@ -96,8 +96,7 @@ public class DefaultPooledObjectInfo imp
         // TODO Simplify this once getBorrowedCount has been added to PooledObject
         if (pooledObject instanceof DefaultPooledObject) {
             return ((DefaultPooledObject<?>) pooledObject).getBorrowedCount();
-        } else {
-            return -1;
         }
+        return -1;
     }
 }

Modified: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java?rev=1701089&r1=1701088&r2=1701089&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
Thu Sep  3 18:03:35 2015
@@ -225,9 +225,8 @@ public class GenericKeyedObjectPool<K,T>
         int maxIdlePerKeySave = getMaxIdlePerKey();
         if (this.minIdlePerKey > maxIdlePerKeySave) {
             return maxIdlePerKeySave;
-        } else {
-            return minIdlePerKey;
         }
+        return minIdlePerKey;
     }
 
     /**
@@ -483,9 +482,8 @@ public class GenericKeyedObjectPool<K,T>
             if (state != PooledObjectState.ALLOCATED) {
                 throw new IllegalStateException(
                         "Object has already been returned to this pool or is invalid");
-            } else {
-                p.markReturning(); // Keep from being marked abandoned (once GKOP does this)
             }
+            p.markReturning(); // Keep from being marked abandoned (once GKOP does this)
         }
 
         long activeTime = p.getActiveTimeMillis();
@@ -687,9 +685,8 @@ public class GenericKeyedObjectPool<K,T>
         if (objectDeque != null) {
             return objectDeque.getAllObjects().size() -
                     objectDeque.getIdleObjects().size();
-        } else {
-            return 0;
         }
+        return 0;
     }
 
 
@@ -1016,9 +1013,8 @@ public class GenericKeyedObjectPool<K,T>
                 numTotal.decrementAndGet();
                 if (getNumIdle() == 0) {
                     return null;
-                } else {
-                    clearOldest();
                 }
+                clearOldest();
             } else {
                 loop = false;
             }
@@ -1080,9 +1076,8 @@ public class GenericKeyedObjectPool<K,T>
                     numTotal.decrementAndGet();
                 }
                 return true;
-            } else {
-                return false;
             }
+            return false;
         } finally {
             deregister(key);
         }

Modified: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericObjectPool.java?rev=1701089&r1=1701088&r2=1701089&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericObjectPool.java
Thu Sep  3 18:03:35 2015
@@ -219,9 +219,8 @@ public class GenericObjectPool<T> extend
         int maxIdleSave = getMaxIdle();
         if (this.minIdle > maxIdleSave) {
             return maxIdleSave;
-        } else {
-            return minIdle;
         }
+        return minIdle;
     }
 
     /**
@@ -540,9 +539,8 @@ public class GenericObjectPool<T> extend
             if (!isAbandonedConfig()) {
                 throw new IllegalStateException(
                         "Returned object not currently part of this pool");
-            } else {
-                return; // Object was abandoned and removed
             }
+            return; // Object was abandoned and removed
         }
 
         synchronized(p) {
@@ -550,9 +548,8 @@ public class GenericObjectPool<T> extend
             if (state != PooledObjectState.ALLOCATED) {
                 throw new IllegalStateException(
                         "Object has already been returned to this pool or is invalid");
-            } else {
-                p.markReturning(); // Keep from being marked abandoned
             }
+            p.markReturning(); // Keep from being marked abandoned
         }
 
         long activeTime = p.getActiveTimeMillis();
@@ -636,10 +633,9 @@ public class GenericObjectPool<T> extend
         if (p == null) {
             if (isAbandonedConfig()) {
                 return;
-            } else {
-                throw new IllegalStateException(
-                        "Invalidated object not currently part of this pool");
             }
+            throw new IllegalStateException(
+                    "Invalidated object not currently part of this pool");
         }
         synchronized (p) {
             if (p.getState() != PooledObjectState.INVALID) {
@@ -992,10 +988,9 @@ public class GenericObjectPool<T> extend
         int numTestsPerEvictionRun = getNumTestsPerEvictionRun();
         if (numTestsPerEvictionRun >= 0) {
             return Math.min(numTestsPerEvictionRun, idleObjects.size());
-        } else {
-            return (int) (Math.ceil(idleObjects.size() /
-                    Math.abs((double) numTestsPerEvictionRun)));
         }
+        return (int) (Math.ceil(idleObjects.size() /
+                Math.abs((double) numTestsPerEvictionRun)));
     }
 
     /**
@@ -1066,9 +1061,8 @@ public class GenericObjectPool<T> extend
     public int getNumWaiters() {
         if (getBlockWhenExhausted()) {
             return idleObjects.getTakeQueueLength();
-        } else {
-            return 0;
         }
+        return 0;
     }
 
     /**

Modified: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PoolImplUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PoolImplUtils.java?rev=1701089&r1=1701088&r2=1701089&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PoolImplUtils.java
(original)
+++ commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PoolImplUtils.java
Thu Sep  3 18:03:35 2015
@@ -113,14 +113,13 @@ class PoolImplUtils {
     private static Object getTypeParameter(Class<?> clazz, Type argType) {
         if (argType instanceof Class<?>) {
             return argType;
-        } else {
-            TypeVariable<?>[] tvs = clazz.getTypeParameters();
-            for (int i = 0; i < tvs.length; i++) {
-                if (tvs[i].equals(argType)) {
-                    return Integer.valueOf(i);
-                }
+        }
+        TypeVariable<?>[] tvs = clazz.getTypeParameters();
+        for (int i = 0; i < tvs.length; i++) {
+            if (tvs[i].equals(argType)) {
+                return Integer.valueOf(i);
             }
-            return null;
         }
+        return null;
     }
 }

Modified: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/SoftReferenceObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/SoftReferenceObjectPool.java?rev=1701089&r1=1701088&r2=1701089&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/SoftReferenceObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/SoftReferenceObjectPool.java
Thu Sep  3 18:03:35 2015
@@ -124,14 +124,13 @@ public class SoftReferenceObjectPool<T>
             if (idleReferences.isEmpty()) {
                 if (null == factory) {
                     throw new NoSuchElementException();
-                } else {
-                    newlyCreated = true;
-                    obj = factory.makeObject().getObject();
-                    createCount++;
-                    // Do not register with the queue
-                    ref = new PooledSoftReference<T>(new SoftReference<T>(obj));
-                    allReferences.add(ref);
                 }
+                newlyCreated = true;
+                obj = factory.makeObject().getObject();
+                createCount++;
+                // Do not register with the queue
+                ref = new PooledSoftReference<T>(new SoftReference<T>(obj));
+                allReferences.add(ref);
             } else {
                 ref = idleReferences.pollFirst();
                 obj = ref.getObject();

Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/WaiterFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/WaiterFactory.java?rev=1701089&r1=1701088&r2=1701089&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/WaiterFactory.java (original)
+++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/WaiterFactory.java Thu
Sep  3 18:03:35 2015
@@ -120,9 +120,8 @@ KeyedPooledObjectFactory<K,Waiter> {
             if (activeCount >= maxActive) {
                 throw new IllegalStateException("Too many active instances: " +
                 activeCount + " in circulation with maxActive = " + maxActive);
-            } else {
-                activeCount++;
             }
+            activeCount++;
         }
         doWait(makeLatency);
         return new DefaultPooledObject<Waiter>(new Waiter(false, true, waiterLatency));
@@ -202,9 +201,8 @@ KeyedPooledObjectFactory<K,Waiter> {
                     "instances for key = " + key + ": " + count.intValue() +
                     " in circulation " + "with maxActivePerKey = " +
                     maxActivePerKey);
-                } else {
-                    activeCounts.put(key, Integer.valueOf(count.intValue() + 1));
                 }
+                activeCounts.put(key, Integer.valueOf(count.intValue() + 1));
             }
         }
         return makeObject();

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=1701089&r1=1701088&r2=1701089&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 Sep  3 18:03:35 2015
@@ -413,10 +413,9 @@ class PooledTestObject implements Tracke
             // Abandoned object sweep will occur no matter what the value of removeAbandonedTimeout,
             // because this indicates that this object was last used decades ago
             return 1;
-        } else {
-            // Abandoned object sweep won't clean up this object
-            return 0;
         }
+        // Abandoned object sweep won't clean up this object
+        return 0;
     }
 
     @Override

Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java?rev=1701089&r1=1701088&r2=1701089&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
Thu Sep  3 18:03:35 2015
@@ -1852,9 +1852,8 @@ public class TestGenericKeyedObjectPool
             doWait(validateLatency);
             if (enableValidation) {
                 return validateCounter++%2 == 0 ? evenValid : oddValid;
-            } else {
-                return valid;
             }
+            return valid;
         }
         @Override
         public void activateObject(K key, PooledObject<String> obj) throws Exception
{

Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java?rev=1701089&r1=1701088&r2=1701089&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java
Thu Sep  3 18:03:35 2015
@@ -1040,9 +1040,8 @@ public class TestGenericObjectPool exten
                 int idleCount) {
             if (callCount.incrementAndGet() > 1500) {
                 return true;
-            } else {
-                return false;
             }
+            return false;
         }
     }
 
@@ -1793,9 +1792,7 @@ public class TestGenericObjectPool exten
             if (validate) {
                 return counter%2 == 0 ? evenTest : oddTest;
             }
-            else {
-                return true;
-            }
+            return true;
         }
         @Override
         public void activateObject(PooledObject<String> obj) throws Exception {
@@ -2307,9 +2304,8 @@ public class TestGenericObjectPool exten
             public void onSwallowException(Exception e) {
                 if (swallowedExceptions.size() == 2) {
                     throw new OutOfMemoryError();
-                } else {
-                    swallowedExceptions.add(e);
                 }
+                swallowedExceptions.add(e);
             }
         };
         pool.setSwallowedExceptionListener(listener);

Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestSoftRefOutOfMemory.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestSoftRefOutOfMemory.java?rev=1701089&r1=1701088&r2=1701089&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestSoftRefOutOfMemory.java
(original)
+++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestSoftRefOutOfMemory.java
Thu Sep  3 18:03:35 2015
@@ -276,9 +276,8 @@ public class TestSoftRefOutOfMemory {
             }
             if (trigger.equals(OomeTrigger.DESTROY)) {
                 return false;
-            } else {
-                return true;
             }
+            return true;
         }
 
         @Override



Mime
View raw message