commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1563703 - in /commons/proper/dbcp/trunk/src: main/java/org/apache/commons/dbcp2/ main/java/org/apache/commons/dbcp2/cpdsadapter/ main/java/org/apache/commons/dbcp2/managed/ test/java/org/apache/commons/dbcp2/
Date Sun, 02 Feb 2014 20:12:32 GMT
Author: markt
Date: Sun Feb  2 20:12:31 2014
New Revision: 1563703

URL: http://svn.apache.org/r1563703
Log:
Partial fix for DBCP-404
Make mutable fields private

Modified:
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DataSourceConnectionFactory.java
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DelegatingDatabaseMetaData.java
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolableConnection.java
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolingConnection.java
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/cpdsadapter/ConnectionImpl.java
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/ManagedConnection.java
    commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestDelegatingConnection.java

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DataSourceConnectionFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DataSourceConnectionFactory.java?rev=1563703&r1=1563702&r2=1563703&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DataSourceConnectionFactory.java
(original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DataSourceConnectionFactory.java
Sun Feb  2 20:12:31 2014
@@ -5,16 +5,15 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.commons.dbcp2;
 
 import java.sql.Connection;
@@ -47,7 +46,7 @@ public class DataSourceConnectionFactory
         }
     }
 
-    protected String _uname = null; // TODO make private?
-    protected String _passwd = null; // TODO make private?
-    protected DataSource _source = null; // TODO make private?
+    private final String _uname;
+    private final String _passwd;
+    private final DataSource _source;
 }

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java?rev=1563703&r1=1563702&r2=1563703&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java
(original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java
Sun Feb  2 20:12:31 2014
@@ -75,7 +75,7 @@ public class DelegatingConnection<C exte
     /** My delegate {@link Connection}. */
     private C _conn = null;
 
-    protected boolean _closed = false; // TODO make private and add getter/setter?
+    private boolean _closed = false;
 
     private boolean _cacheState = true;
     private Boolean _autoCommitCached = null;
@@ -249,6 +249,14 @@ public class DelegatingConnection<C exte
         }
     }
 
+    protected boolean isClosedInternal() {
+        return _closed;
+    }
+
+    protected void setClosedInternal(boolean closed) {
+        this._closed = closed;
+    }
+
     protected final void closeInternal() throws SQLException {
         try {
             passivate();

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DelegatingDatabaseMetaData.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DelegatingDatabaseMetaData.java?rev=1563703&r1=1563702&r2=1563703&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DelegatingDatabaseMetaData.java
(original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DelegatingDatabaseMetaData.java
Sun Feb  2 20:12:31 2014
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.commons.dbcp2;
 
 import java.sql.Connection;
@@ -36,10 +35,10 @@ import java.sql.SQLException;
 public class DelegatingDatabaseMetaData implements DatabaseMetaData {
 
     /** My delegate {@link DatabaseMetaData} */
-    protected DatabaseMetaData _meta; // TODO make final and private?
+    private final DatabaseMetaData _meta;
 
     /** The connection that created me. **/
-    protected DelegatingConnection<?> _conn = null; // TODO make final and private?
+    private final DelegatingConnection<?> _conn;
 
     public DelegatingDatabaseMetaData(DelegatingConnection<?> c,
             DatabaseMetaData m) {

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolableConnection.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolableConnection.java?rev=1563703&r1=1563702&r2=1563703&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolableConnection.java
(original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolableConnection.java
Sun Feb  2 20:12:31 2014
@@ -49,7 +49,7 @@ public class PoolableConnection extends 
 
     @Override
     public boolean isClosed() throws SQLException {
-        if (_closed) {
+        if (isClosedInternal()) {
             return true;
         }
 
@@ -71,7 +71,7 @@ public class PoolableConnection extends 
      */
      @Override
     public synchronized void close() throws SQLException {
-        if (_closed) {
+        if (isClosedInternal()) {
             // already closed
             return;
         }
@@ -121,7 +121,7 @@ public class PoolableConnection extends 
                 throw (SQLException) new SQLException("Cannot close connection (invalidating
pooled object failed)").initCause(e);
             }
         }
-        _closed = true;
+        setClosedInternal(true);
     }
 
     /**

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolingConnection.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolingConnection.java?rev=1563703&r1=1563702&r2=1563703&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolingConnection.java
(original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolingConnection.java
Sun Feb  2 20:12:31 2014
@@ -96,7 +96,7 @@ public class PoolingConnection extends D
             try {
                 getDelegateInternal().close();
             } finally {
-                _closed = true;
+                setClosedInternal(true);
             }
         }
     }

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/cpdsadapter/ConnectionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/cpdsadapter/ConnectionImpl.java?rev=1563703&r1=1563702&r2=1563703&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/cpdsadapter/ConnectionImpl.java
(original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/cpdsadapter/ConnectionImpl.java
Sun Feb  2 20:12:31 2014
@@ -73,11 +73,11 @@ class ConnectionImpl extends DelegatingC
      */
     @Override
     public void close() throws SQLException {
-        if (!_closed) {
+        if (!isClosedInternal()) {
             try {
                 passivate();
             } finally {
-                _closed = true;
+                setClosedInternal(true);
                 pooledConnection.notifyListeners();
             }
         }

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/ManagedConnection.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/ManagedConnection.java?rev=1563703&r1=1563702&r2=1563703&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/ManagedConnection.java
(original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/ManagedConnection.java
Sun Feb  2 20:12:31 2014
@@ -150,7 +150,7 @@ public class ManagedConnection<C extends
 
     @Override
     public void close() throws SQLException {
-        if (!_closed) {
+        if (!isClosedInternal()) {
             try {
                 // Don't actually close the connection if in a transaction. The
                 // connection will be closed by the transactionComplete method.
@@ -158,7 +158,7 @@ public class ManagedConnection<C extends
                     super.close();
                 }
             } finally {
-                _closed = true;
+                setClosedInternal(true);
             }
         }
     }
@@ -189,7 +189,7 @@ public class ManagedConnection<C extends
         // If this connection was closed during the transaction and there is
         // still a delegate present close it
         Connection delegate = getDelegateInternal();
-        if (_closed && delegate != null) {
+        if (isClosedInternal() && delegate != null) {
             try {
                 setDelegate(null);
 

Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestDelegatingConnection.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestDelegatingConnection.java?rev=1563703&r1=1563702&r2=1563703&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestDelegatingConnection.java
(original)
+++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestDelegatingConnection.java
Sun Feb  2 20:12:31 2014
@@ -112,7 +112,7 @@ public class TestDelegatingConnection ex
 
         try {
             conn = new DelegatingConnection<>(null);
-            conn._closed = true;
+            conn.setClosedInternal(true);
             conn.checkOpen();
             fail("Expecting SQLException");
         } catch (SQLException ex) {



Mime
View raw message