You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2011/04/24 22:27:29 UTC

svn commit: r1096378 - /commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java

Author: simonetripodi
Date: Sun Apr 24 20:27:29 2011
New Revision: 1096378

URL: http://svn.apache.org/viewvc?rev=1096378&view=rev
Log:
removed unnecessary else statements, moving the code outside

Modified:
    commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java

Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java?rev=1096378&r1=1096377&r2=1096378&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java (original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java Sun Apr 24 20:27:29 2011
@@ -1196,9 +1196,8 @@ public class GenericKeyedObjectPool<K,V>
                                     }
                                 }
                                 throw new NoSuchElementException("Timeout waiting for idle object");
-                            } else {
-                                continue; // keep looping
                             }
+                            continue; // keep looping
                         default:
                             throw new IllegalArgumentException("whenExhaustedAction " + whenExhaustedAction +
                                     " not recognized.");
@@ -1257,9 +1256,7 @@ public class GenericKeyedObjectPool<K,V>
                        "Could not create a validated object, cause: " +
                             e.getMessage());
                 }
-                else {
-                    continue; // keep looping
-                }
+                continue; // keep looping
             }
         }
     }
@@ -1457,9 +1454,8 @@ public class GenericKeyedObjectPool<K,V>
             pool = _poolMap.remove(key);
             if (pool == null) {
                 return;
-            } else {
-                _poolList.remove(key);
             }
+            _poolList.remove(key);
             // Copy objects to new list so pool.queue can be cleared inside
             // the sync
             List<ObjectTimestampPair<V>> objects = new ArrayList<ObjectTimestampPair<V>>();
@@ -1827,26 +1823,25 @@ public class GenericKeyedObjectPool<K,V>
             assertOpen();
             if (0 < getNumActive()) {
                 throw new IllegalStateException("Objects are already active");
-            } else {
-                for (Iterator<K> it = _poolMap.keySet().iterator(); it.hasNext();) {
-                    K key = it.next();
-                    ObjectQueue pool = _poolMap.get(key);
-                    if (pool != null) {
-                        // Copy objects to new list so pool.queue can be cleared
-                        // inside the sync
-                        List objects = new ArrayList();
-                        objects.addAll(pool.queue);
-                        toDestroy.put(key, objects);
-                        it.remove();
-                        _poolList.remove(key);
-                        _totalIdle = _totalIdle - pool.queue.size();
-                        _totalInternalProcessing =
-                            _totalInternalProcessing + pool.queue.size();
-                        pool.queue.clear();
-                    }
+            }
+            for (Iterator<K> it = _poolMap.keySet().iterator(); it.hasNext();) {
+                K key = it.next();
+                ObjectQueue pool = _poolMap.get(key);
+                if (pool != null) {
+                    // Copy objects to new list so pool.queue can be cleared
+                    // inside the sync
+                    List objects = new ArrayList();
+                    objects.addAll(pool.queue);
+                    toDestroy.put(key, objects);
+                    it.remove();
+                    _poolList.remove(key);
+                    _totalIdle = _totalIdle - pool.queue.size();
+                    _totalInternalProcessing =
+                        _totalInternalProcessing + pool.queue.size();
+                    pool.queue.clear();
                 }
-                _factory = factory;
             }
+            _factory = factory;
         }
         destroy(toDestroy, oldFactory);
     }
@@ -2162,9 +2157,8 @@ public class GenericKeyedObjectPool<K,V>
     private synchronized int getNumTests() {
         if (_numTestsPerEvictionRun >= 0) {
             return Math.min(_numTestsPerEvictionRun, _totalIdle);
-        } else {
-            return(int)(Math.ceil(_totalIdle/Math.abs((double)_numTestsPerEvictionRun)));
         }
+        return(int)(Math.ceil(_totalIdle/Math.abs((double)_numTestsPerEvictionRun)));
     }
 
     /**
@@ -2315,10 +2309,9 @@ public class GenericKeyedObjectPool<K,V>
                 // make sure the natural ordering is consistent with equals
                 // see java.lang.Comparable Javadocs
                 return System.identityHashCode(this) - System.identityHashCode(other);
-            } else {
-                // handle int overflow
-                return (int)Math.min(Math.max(tstampdiff, Integer.MIN_VALUE), Integer.MAX_VALUE);
             }
+            // handle int overflow
+            return (int)Math.min(Math.max(tstampdiff, Integer.MIN_VALUE), Integer.MAX_VALUE);
         }
 
         /**