commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1563708 - in /commons/proper/dbcp/trunk/src: changes/changes.xml main/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java main/java/org/apache/commons/dbcp2/managed/PoolableManagedConnectionFactory.java
Date Sun, 02 Feb 2014 20:38:03 GMT
Author: markt
Date: Sun Feb  2 20:38:02 2014
New Revision: 1563708

URL: http://svn.apache.org/r1563708
Log:
Fix DBCP-404
Mutable fields should be private

Modified:
    commons/proper/dbcp/trunk/src/changes/changes.xml
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/PoolableManagedConnectionFactory.java

Modified: commons/proper/dbcp/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/changes/changes.xml?rev=1563708&r1=1563707&r2=1563708&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/changes/changes.xml (original)
+++ commons/proper/dbcp/trunk/src/changes/changes.xml Sun Feb  2 20:38:02 2014
@@ -104,6 +104,9 @@ The <action> type attribute can be add,u
         connection is consistent when the underlying connection is closed as a
         result of an error condition.
       </action>
+      <action dev="markt" issue="DBCP-404" type="fix">
+        Make all mutable fields private.
+      </action>
     </release>
     <release version="1.5.1" date="TBD" description="TBD">
       <action dev="markt" issue="DBCP-400" type="fix">

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java?rev=1563708&r1=1563707&r2=1563708&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java
(original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java
Sun Feb  2 20:38:02 2014
@@ -348,20 +348,35 @@ public class PoolableConnectionFactory
         }
     }
 
+    protected ConnectionFactory getConnectionFactory() {
+        return _connFactory;
+    }
+
+    protected boolean getPoolStatements() {
+        return poolStatements;
+    }
+
+    protected int getMaxOpenPreparedStatements() {
+        return maxOpenPreparedStatements;
+    }
+
+    protected boolean getCacheState() {
+        return _cacheState;
+    }
 
-    protected final ConnectionFactory _connFactory;
+    private final ConnectionFactory _connFactory;
     private final ObjectName dataSourceJmxName;
-    protected volatile String _validationQuery = null;
-    protected volatile int _validationQueryTimeout = -1;
-    protected Collection<String> _connectionInitSqls = null;
-    protected volatile ObjectPool<PoolableConnection> _pool = null;
-    protected Boolean _defaultReadOnly = null;
-    protected boolean _defaultAutoCommit = true;
-    protected int _defaultTransactionIsolation = UNKNOWN_TRANSACTIONISOLATION;
-    protected String _defaultCatalog;
-    protected boolean _cacheState;
-    protected boolean poolStatements = false;
-    protected int maxOpenPreparedStatements =
+    private volatile String _validationQuery = null;
+    private volatile int _validationQueryTimeout = -1;
+    private Collection<String> _connectionInitSqls = null;
+    private volatile ObjectPool<PoolableConnection> _pool = null;
+    private Boolean _defaultReadOnly = null;
+    private boolean _defaultAutoCommit = true;
+    private int _defaultTransactionIsolation = UNKNOWN_TRANSACTIONISOLATION;
+    private String _defaultCatalog;
+    private boolean _cacheState;
+    private boolean poolStatements = false;
+    private int maxOpenPreparedStatements =
         GenericKeyedObjectPoolConfig.DEFAULT_MAX_TOTAL_PER_KEY;
     private long maxConnLifetimeMillis = -1;
 

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/PoolableManagedConnectionFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/PoolableManagedConnectionFactory.java?rev=1563708&r1=1563707&r2=1563708&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/PoolableManagedConnectionFactory.java
(original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/PoolableManagedConnectionFactory.java
Sun Feb  2 20:38:02 2014
@@ -61,26 +61,25 @@ public class PoolableManagedConnectionFa
      */
     @Override
     synchronized public PooledObject<PoolableConnection> makeObject() throws Exception
{
-        Connection conn = _connFactory.createConnection();
+        Connection conn = getConnectionFactory().createConnection();
         if (conn == null) {
             throw new IllegalStateException("Connection factory returned null from createConnection");
         }
         initializeConnection(conn);
-        if(poolStatements) {
+        if(getPoolStatements()) {
             conn = new PoolingConnection(conn);
             GenericKeyedObjectPoolConfig config = new GenericKeyedObjectPoolConfig();
             config.setMaxTotalPerKey(-1);
             config.setBlockWhenExhausted(false);
             config.setMaxWaitMillis(0);
             config.setMaxIdlePerKey(1);
-            config.setMaxTotal(maxOpenPreparedStatements);
+            config.setMaxTotal(getMaxOpenPreparedStatements());
             KeyedObjectPool<PStmtKey,DelegatingPreparedStatement> stmtPool =
                 new GenericKeyedObjectPool<>((PoolingConnection)conn, config);
             ((PoolingConnection)conn).setStatementPool(stmtPool);
-            ((PoolingConnection) conn).setCacheState(_cacheState);
+            ((PoolingConnection) conn).setCacheState(getCacheState());
         }
         return new DefaultPooledObject<PoolableConnection>(
-                new PoolableManagedConnection(transactionRegistry, conn, _pool));
+                new PoolableManagedConnection(transactionRegistry, conn, getPool()));
     }
-
 }



Mime
View raw message