commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject svn commit: r635174 - in /commons/proper/dbcp/trunk: src/java/org/apache/commons/dbcp/datasources/CPDSConnectionFactory.java src/java/org/apache/commons/dbcp/datasources/KeyedCPDSConnectionFactory.java xdocs/changes.xml
Date Sun, 09 Mar 2008 06:31:18 GMT
Author: psteitz
Date: Sat Mar  8 22:31:16 2008
New Revision: 635174

URL: http://svn.apache.org/viewvc?rev=635174&view=rev
Log:
Fixed inconsistent synchronization on _rollbackAfterValidation,
_validationQuery and _pool by making the first two volatile and making both
getter and setter for _pool synchronized.
JIRA: DBCP-252

Modified:
    commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/datasources/CPDSConnectionFactory.java
    commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/datasources/KeyedCPDSConnectionFactory.java
    commons/proper/dbcp/trunk/xdocs/changes.xml

Modified: commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/datasources/CPDSConnectionFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/datasources/CPDSConnectionFactory.java?rev=635174&r1=635173&r2=635174&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/datasources/CPDSConnectionFactory.java
(original)
+++ commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/datasources/CPDSConnectionFactory.java
Sat Mar  8 22:31:16 2008
@@ -49,8 +49,8 @@
             + "I have no record of the underlying PooledConnection.";
 
     protected ConnectionPoolDataSource _cpds = null;
-    protected String _validationQuery = null;
-    protected boolean _rollbackAfterValidation = false;
+    protected volatile String _validationQuery = null;
+    protected volatile boolean _rollbackAfterValidation = false;
     protected ObjectPool _pool = null;
     protected String _username = null;
     protected String _password = null;
@@ -121,33 +121,33 @@
 
     /**
      * Sets the query I use to {*link #validateObject validate}
-     * {*link Connection}s.
+     * {@link Connection}s.
      * Should return at least one row.
-     * May be <tt>null</tt>
-     * @param validationQuery a query to use to {*link #validateObject validate}
-     *        {*link Connection}s.
+     * May be <code>null</code>
+     * @param validationQuery a query to use to {@link #validateObject validate}
+     *        {@link Connection}s.
      */
-    public synchronized void setValidationQuery(String validationQuery) {
+    public void setValidationQuery(String validationQuery) {
         _validationQuery = validationQuery;
     }
 
     /**
      * Sets whether a rollback should be issued after 
-     * {*link #validateObject validating} 
-     * {*link Connection}s.
+     * {@link #validateObject validating} 
+     * {@link Connection}s.
      * @param rollbackAfterValidation whether a rollback should be issued after
-     *        {*link #validateObject validating} 
-     *        {*link Connection}s.
+     *        {@link #validateObject validating} 
+     *        {@link Connection}s.
      */
-    public synchronized void setRollbackAfterValidation(
+    public void setRollbackAfterValidation(
             boolean rollbackAfterValidation) {
         _rollbackAfterValidation = rollbackAfterValidation;
     }
 
     /**
-     * Sets the {*link ObjectPool} in which to pool {*link Connection}s.
+     * Sets the {@link ObjectPool} in which to pool {*link Connection}s.
      * @param pool the {*link ObjectPool} in which to pool those
-     *        {*link Connection}s
+     *        {@link Connection}s
      */
     public synchronized void setPool(ObjectPool pool) throws SQLException {
         if (null != _pool && pool != _pool) {
@@ -162,7 +162,11 @@
         _pool = pool;
     }
 
-    public ObjectPool getPool() {
+    /**
+     * Gets the {@link ObjectPool} for {@link Connection}s.
+     * @return connection pool
+     */
+    public synchronized ObjectPool getPool() {
         return _pool;
     }
 

Modified: commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/datasources/KeyedCPDSConnectionFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/datasources/KeyedCPDSConnectionFactory.java?rev=635174&r1=635173&r2=635174&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/datasources/KeyedCPDSConnectionFactory.java
(original)
+++ commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/datasources/KeyedCPDSConnectionFactory.java
Sat Mar  8 22:31:16 2008
@@ -50,8 +50,8 @@
             + "I have no record of the underlying PooledConnection.";
 
     protected ConnectionPoolDataSource _cpds = null;
-    protected String _validationQuery = null;
-    protected boolean _rollbackAfterValidation = false;
+    protected volatile String _validationQuery = null;
+    protected volatile boolean _rollbackAfterValidation = false;
     protected KeyedObjectPool _pool = null;
     
     /** 
@@ -118,22 +118,22 @@
     /**
      * Sets the query I use to {*link #validateObject validate} {*link Connection}s.
      * Should return at least one row.
-     * May be <tt>null</tt>
+     * May be <code>null</code>
      * @param validationQuery a query to use to {*link #validateObject validate} {*link Connection}s.
      */
-    synchronized public void setValidationQuery(String validationQuery) {
+    public void setValidationQuery(String validationQuery) {
         _validationQuery = validationQuery;
     }
 
     /**
      * Sets whether a rollback should be issued after 
-     * {*link #validateObject validating} 
-     * {*link Connection}s.
+     * {@link #validateObject validating} 
+     * {@link Connection}s.
      * @param rollbackAfterValidation whether a rollback should be issued after
-     *        {*link #validateObject validating} 
-     *        {*link Connection}s.
+     *        {@link #validateObject validating} 
+     *        {@link Connection}s.
      */
-    public synchronized void setRollbackAfterValidation(
+    public void setRollbackAfterValidation(
             boolean rollbackAfterValidation) {
         _rollbackAfterValidation = rollbackAfterValidation;
     }
@@ -156,7 +156,7 @@
         _pool = pool;
     }
 
-    public KeyedObjectPool getPool() {
+    public synchronized KeyedObjectPool getPool() {
         return _pool;
     }
 

Modified: commons/proper/dbcp/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/xdocs/changes.xml?rev=635174&r1=635173&r2=635174&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/xdocs/changes.xml (original)
+++ commons/proper/dbcp/trunk/xdocs/changes.xml Sat Mar  8 22:31:16 2008
@@ -114,6 +114,12 @@
         Made getPool synchronized in PoolableConnectionFactory.
         Fixes inconsistent synchronization accessing _pool.
       </action> 
+      <action dev="psteitz" type="fix" issue="DBCP-252" due-to="FindBugs">
+        Fixed inconsistent synchronization on _rollbackAfterValidation,
+        _validationQuery and _pool in CPDSConnectionFactory and 
+        KeyedCPDSConnectionFactory by making the first two volatile and making
+        both getter and setter for _pool synchronized.
+      </action> 
     </release>
     <release version="1.2.2" date="2007-04-04"
       description="This is a maintenance release containing bug fixes



Mime
View raw message