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 2012/06/17 23:09:06 UTC

svn commit: r1351161 - in /commons/proper/pool/trunk/src: changes/changes.xml main/java/org/apache/commons/pool2/PoolUtils.java

Author: markt
Date: Sun Jun 17 21:09:04 2012
New Revision: 1351161

URL: http://svn.apache.org/viewvc?rev=1351161&view=rev
Log:
Fix POOL-217
Use an IODH for PoolUtils.MIN_IDLE_TIMER
Based on a patch by sebb

Modified:
    commons/proper/pool/trunk/src/changes/changes.xml
    commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/PoolUtils.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=1351161&r1=1351160&r2=1351161&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/changes/changes.xml (original)
+++ commons/proper/pool/trunk/src/changes/changes.xml Sun Jun 17 21:09:04 2012
@@ -52,6 +52,9 @@ clarify behaviour and improve consistenc
     <action issue="POOL-221" dev="markt" type="fix" >
       PooledObject.state does not need to be volatile.
     </action>
+    <action issue="POOL-217" dev="markt" type="update"  due-to="sebb">
+      Use an IODH for PoolUtils.MIN_IDLE_TIMER
+    </action>
     <action issue="POOL-216" dev="markt" type="update" >
       GenericKeyedObjectPool.ensureMinIdle(K) does not need to check getMinIdlePerKey().
     </action>

Modified: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/PoolUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/PoolUtils.java?rev=1351161&r1=1351160&r2=1351161&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/PoolUtils.java (original)
+++ commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/PoolUtils.java Sun Jun 17 21:09:04 2012
@@ -40,9 +40,11 @@ public final class PoolUtils {
 
     /**
      * Timer used to periodically check pools idle object count. Because a
-     * {@link Timer} creates a {@link Thread} this is lazily instantiated.
+     * {@link Timer} creates a {@link Thread}, an IODH is used.
      */
-    private static Timer MIN_IDLE_TIMER; // @GuardedBy("PoolUtils.class")
+    static class TimerHolder {
+        static final Timer MIN_IDLE_TIMER = new Timer(true);
+    }
 
     /**
      * PoolUtils instances should NOT be constructed in standard programming.
@@ -553,16 +555,12 @@ public final class PoolUtils {
     }
 
     /**
-     * Get the <code>Timer</code> for checking keyedPool's idle count. Lazily
-     * create the {@link Timer} as needed.
+     * Get the <code>Timer</code> for checking keyedPool's idle count.
      *
      * @return the {@link Timer} for checking keyedPool's idle count.
      */
-    private static synchronized Timer getMinIdleTimer() {
-        if (MIN_IDLE_TIMER == null) {
-            MIN_IDLE_TIMER = new Timer(true);
-        }
-        return MIN_IDLE_TIMER;
+    private static Timer getMinIdleTimer() {
+        return TimerHolder.MIN_IDLE_TIMER;
     }
 
     /**