You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ps...@apache.org on 2007/12/12 04:45:22 UTC

svn commit: r603449 - in /commons/proper/pool/branches/1_4_RELEASE_BRANCH: src/java/org/apache/commons/pool/impl/ xdocs/

Author: psteitz
Date: Tue Dec 11 19:45:21 2007
New Revision: 603449

URL: http://svn.apache.org/viewvc?rev=603449&view=rev
Log:
Made _testOnBorrow, _testOnReturn volatile and removed syncrhonization in
associated getters and setters in GenericObjectPool, GenericKeyedObjectPool.
Made getNumIdle synchronized in StackKeyedObjectPool. 

JIRA: POOL-113
Reported and by Sebastian Bazley (grace FindBugs)

Modified:
    commons/proper/pool/branches/1_4_RELEASE_BRANCH/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java
    commons/proper/pool/branches/1_4_RELEASE_BRANCH/src/java/org/apache/commons/pool/impl/GenericObjectPool.java
    commons/proper/pool/branches/1_4_RELEASE_BRANCH/src/java/org/apache/commons/pool/impl/StackKeyedObjectPool.java
    commons/proper/pool/branches/1_4_RELEASE_BRANCH/xdocs/changes.xml

Modified: commons/proper/pool/branches/1_4_RELEASE_BRANCH/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/branches/1_4_RELEASE_BRANCH/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java?rev=603449&r1=603448&r2=603449&view=diff
==============================================================================
--- commons/proper/pool/branches/1_4_RELEASE_BRANCH/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java (original)
+++ commons/proper/pool/branches/1_4_RELEASE_BRANCH/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java Tue Dec 11 19:45:21 2007
@@ -616,7 +616,7 @@
      * @return <code>true</code> if objects are validated before being borrowed.
      * @see #setTestOnBorrow
      */
-    public synchronized boolean getTestOnBorrow() {
+    public boolean getTestOnBorrow() {
         return _testOnBorrow;
     }
 
@@ -631,7 +631,7 @@
      * @param testOnBorrow whether object should be validated before being returned by borrowObject.
      * @see #getTestOnBorrow
      */
-    public synchronized void setTestOnBorrow(boolean testOnBorrow) {
+    public void setTestOnBorrow(boolean testOnBorrow) {
         _testOnBorrow = testOnBorrow;
     }
 
@@ -644,7 +644,7 @@
      * @return <code>true</code> when objects will be validated before being borrowed.
      * @see #setTestOnReturn
      */
-    public synchronized boolean getTestOnReturn() {
+    public boolean getTestOnReturn() {
         return _testOnReturn;
     }
 
@@ -657,7 +657,7 @@
      * @param testOnReturn <code>true</code> so objects will be validated before being borrowed.
      * @see #getTestOnReturn
      */
-    public synchronized void setTestOnReturn(boolean testOnReturn) {
+    public void setTestOnReturn(boolean testOnReturn) {
         _testOnReturn = testOnReturn;
     }
 
@@ -1754,7 +1754,7 @@
      * @see #setTestOnBorrow
      * @see #getTestOnBorrow
      */
-    private boolean _testOnBorrow = DEFAULT_TEST_ON_BORROW;
+    private volatile boolean _testOnBorrow = DEFAULT_TEST_ON_BORROW;
 
     /**
      * When <code>true</code>, objects will be
@@ -1765,7 +1765,7 @@
      * @see #getTestOnReturn
      * @see #setTestOnReturn
      */
-    private boolean _testOnReturn = DEFAULT_TEST_ON_RETURN;
+    private volatile boolean _testOnReturn = DEFAULT_TEST_ON_RETURN;
 
     /**
      * When <code>true</code>, objects will be

Modified: commons/proper/pool/branches/1_4_RELEASE_BRANCH/src/java/org/apache/commons/pool/impl/GenericObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/branches/1_4_RELEASE_BRANCH/src/java/org/apache/commons/pool/impl/GenericObjectPool.java?rev=603449&r1=603448&r2=603449&view=diff
==============================================================================
--- commons/proper/pool/branches/1_4_RELEASE_BRANCH/src/java/org/apache/commons/pool/impl/GenericObjectPool.java (original)
+++ commons/proper/pool/branches/1_4_RELEASE_BRANCH/src/java/org/apache/commons/pool/impl/GenericObjectPool.java Tue Dec 11 19:45:21 2007
@@ -600,7 +600,7 @@
      * @return <code>true</code> if objects are validated before being borrowed.
      * @see #setTestOnBorrow
      */
-    public synchronized boolean getTestOnBorrow() {
+    public boolean getTestOnBorrow() {
         return _testOnBorrow;
     }
 
@@ -615,7 +615,7 @@
      * @param testOnBorrow <code>true</code> if objects should be validated before being borrowed.
      * @see #getTestOnBorrow
      */
-    public synchronized void setTestOnBorrow(boolean testOnBorrow) {
+    public void setTestOnBorrow(boolean testOnBorrow) {
         _testOnBorrow = testOnBorrow;
     }
 
@@ -628,7 +628,7 @@
      * @return <code>true</code> when objects will be validated after returned to {@link #returnObject}.
      * @see #setTestOnReturn
      */
-    public synchronized boolean getTestOnReturn() {
+    public boolean getTestOnReturn() {
         return _testOnReturn;
     }
 
@@ -641,7 +641,7 @@
      * @param testOnReturn <code>true</code> so objects will be validated after returned to {@link #returnObject}.
      * @see #getTestOnReturn
      */
-    public synchronized void setTestOnReturn(boolean testOnReturn) {
+    public void setTestOnReturn(boolean testOnReturn) {
         _testOnReturn = testOnReturn;
     }
 
@@ -1388,7 +1388,7 @@
      * @see #setTestOnBorrow
      * @see #getTestOnBorrow
      */
-    private boolean _testOnBorrow = DEFAULT_TEST_ON_BORROW;
+    private volatile boolean _testOnBorrow = DEFAULT_TEST_ON_BORROW;
 
     /**
      * When <tt>true</tt>, objects will be
@@ -1399,7 +1399,7 @@
      * @see #getTestOnReturn
      * @see #setTestOnReturn
      */
-    private boolean _testOnReturn = DEFAULT_TEST_ON_RETURN;
+    private volatile boolean _testOnReturn = DEFAULT_TEST_ON_RETURN;
 
     /**
      * When <tt>true</tt>, objects will be

Modified: commons/proper/pool/branches/1_4_RELEASE_BRANCH/src/java/org/apache/commons/pool/impl/StackKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/branches/1_4_RELEASE_BRANCH/src/java/org/apache/commons/pool/impl/StackKeyedObjectPool.java?rev=603449&r1=603448&r2=603449&view=diff
==============================================================================
--- commons/proper/pool/branches/1_4_RELEASE_BRANCH/src/java/org/apache/commons/pool/impl/StackKeyedObjectPool.java (original)
+++ commons/proper/pool/branches/1_4_RELEASE_BRANCH/src/java/org/apache/commons/pool/impl/StackKeyedObjectPool.java Tue Dec 11 19:45:21 2007
@@ -297,7 +297,7 @@
      *
      * @return the total number of instances currently idle in this pool
      */
-    public int getNumIdle() {
+    public synchronized int getNumIdle() {
         return _totIdle;
     }
 

Modified: commons/proper/pool/branches/1_4_RELEASE_BRANCH/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/pool/branches/1_4_RELEASE_BRANCH/xdocs/changes.xml?rev=603449&r1=603448&r2=603449&view=diff
==============================================================================
--- commons/proper/pool/branches/1_4_RELEASE_BRANCH/xdocs/changes.xml (original)
+++ commons/proper/pool/branches/1_4_RELEASE_BRANCH/xdocs/changes.xml Tue Dec 11 19:45:21 2007
@@ -103,6 +103,12 @@
         performance problems in DBCP and other applications where factory
         methods could block. Fixes both POOL-93 and POOL-108.
       </action>
+      <action dev="psteitz" type="fix" issue="POOL-113">
+        Made _testOnBorrow, _testOnReturn volatile and removed synchronization
+        in associated getters and setters in GenericObjectPool,
+        GenericKeyedObjectPool. Made getNumIdle synchronized in
+        StackKeyedObjectPool. 
+      </action>
     </release>
 
     <release version="1.3" date="2006-pending" description="1.x bugfix release">