commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1547230 - in /commons/proper/dbcp/branches/DBCP_1_5_x_BRANCH/src: changes/changes.xml java/org/apache/commons/dbcp/PoolableConnectionFactory.java
Date Mon, 02 Dec 2013 22:40:47 GMT
Author: markt
Date: Mon Dec  2 22:40:47 2013
New Revision: 1547230

URL: http://svn.apache.org/r1547230
Log:
Fix POOL-405
Don't make multiple calls to Connection.getAutoCommit() as it could be an expensive call.

Modified:
    commons/proper/dbcp/branches/DBCP_1_5_x_BRANCH/src/changes/changes.xml
    commons/proper/dbcp/branches/DBCP_1_5_x_BRANCH/src/java/org/apache/commons/dbcp/PoolableConnectionFactory.java

Modified: commons/proper/dbcp/branches/DBCP_1_5_x_BRANCH/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/branches/DBCP_1_5_x_BRANCH/src/changes/changes.xml?rev=1547230&r1=1547229&r2=1547230&view=diff
==============================================================================
--- commons/proper/dbcp/branches/DBCP_1_5_x_BRANCH/src/changes/changes.xml (original)
+++ commons/proper/dbcp/branches/DBCP_1_5_x_BRANCH/src/changes/changes.xml Mon Dec  2 22:40:47
2013
@@ -38,6 +38,13 @@ The <action> type attribute can be add,u
     <title>Commons DBCP Release Notes</title>
   </properties>
   <body>
+    <release version="1.5.1" date="TBD" description="TBD">
+      <action dev="markt" issue="DBCP-405" type="fix">
+        Avoid multiple calls to Connection.getAutoCommit() in
+        PoolableConnectionFactory.passivateObject() as it could be an expensive
+        call.
+      </action>
+    </release>
     <release version="1.4.1" date="TBD" description="TBD">
       <action dev="psteitz" issue="DBCP-367" type="fix" due-to="Ken Tatsushita">
         Improved configuration documentation of minIdle (made it match javadoc,

Modified: commons/proper/dbcp/branches/DBCP_1_5_x_BRANCH/src/java/org/apache/commons/dbcp/PoolableConnectionFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/branches/DBCP_1_5_x_BRANCH/src/java/org/apache/commons/dbcp/PoolableConnectionFactory.java?rev=1547230&r1=1547229&r2=1547230&view=diff
==============================================================================
--- commons/proper/dbcp/branches/DBCP_1_5_x_BRANCH/src/java/org/apache/commons/dbcp/PoolableConnectionFactory.java
(original)
+++ commons/proper/dbcp/branches/DBCP_1_5_x_BRANCH/src/java/org/apache/commons/dbcp/PoolableConnectionFactory.java
Mon Dec  2 22:40:47 2013
@@ -79,7 +79,7 @@ public class PoolableConnectionFactory i
         _defaultReadOnly = defaultReadOnly ? Boolean.TRUE : Boolean.FALSE;
         _defaultAutoCommit = defaultAutoCommit;
     }
-    
+
     /**
      * Create a new <tt>PoolableConnectionFactory</tt>.
      * @param connFactory the {@link ConnectionFactory} from which to obtain base {@link
Connection}s
@@ -101,7 +101,7 @@ public class PoolableConnectionFactory i
         _defaultReadOnly = defaultReadOnly ? Boolean.TRUE : Boolean.FALSE;
         _defaultAutoCommit = defaultAutoCommit;
     }
-    
+
     /**
      * Create a new <tt>PoolableConnectionFactory</tt>.
      * @param connFactory the {@link ConnectionFactory} from which to obtain base {@link
Connection}s
@@ -170,7 +170,7 @@ public class PoolableConnectionFactory i
         _defaultAutoCommit = defaultAutoCommit;
         _defaultTransactionIsolation = defaultTransactionIsolation;
     }
-    
+
     /**
      * Create a new <tt>PoolableConnectionFactory</tt>.
      * @param connFactory the {@link ConnectionFactory} from which to obtain base {@link
Connection}s
@@ -194,7 +194,7 @@ public class PoolableConnectionFactory i
         _defaultAutoCommit = defaultAutoCommit;
         _defaultTransactionIsolation = defaultTransactionIsolation;
     }
-    
+
     /**
      * Create a new <tt>PoolableConnectionFactory</tt>.
      * @param connFactory the {@link ConnectionFactory} from which to obtain base {@link
Connection}s
@@ -390,7 +390,7 @@ public class PoolableConnectionFactory i
         _defaultTransactionIsolation = defaultTransactionIsolation;
         _defaultCatalog = defaultCatalog;
     }
-    
+
     /**
      * Create a new <tt>PoolableConnectionFactory</tt>.
      * @param connFactory the {@link ConnectionFactory} from which to obtain base {@link
Connection}s
@@ -429,7 +429,7 @@ public class PoolableConnectionFactory i
         _defaultTransactionIsolation = defaultTransactionIsolation;
         _defaultCatalog = defaultCatalog;
     }
-    
+
     /**
      * Create a new <tt>PoolableConnectionFactory</tt>.
      * @param connFactory the {@link ConnectionFactory} from which to obtain base {@link
Connection}s
@@ -489,7 +489,7 @@ public class PoolableConnectionFactory i
     public void setValidationQuery(String validationQuery) {
         _validationQuery = validationQuery;
     }
-    
+
     /**
      * Sets the validation query timeout, the amount of time, in seconds, that
      * connection validation will wait for a response from the database when
@@ -681,11 +681,12 @@ public class PoolableConnectionFactory i
     public void passivateObject(Object obj) throws Exception {
         if(obj instanceof Connection) {
             Connection conn = (Connection)obj;
-            if(!conn.getAutoCommit() && !conn.isReadOnly()) {
+            boolean connAutoCommit = conn.getAutoCommit();
+            if(!connAutoCommit && !conn.isReadOnly()) {
                 conn.rollback();
             }
             conn.clearWarnings();
-            if(!conn.getAutoCommit()) {
+            if(!connAutoCommit) {
                 conn.setAutoCommit(true);
             }
         }
@@ -703,12 +704,12 @@ public class PoolableConnectionFactory i
             if (conn.getAutoCommit() != _defaultAutoCommit) {
                 conn.setAutoCommit(_defaultAutoCommit);
             }
-            if ((_defaultTransactionIsolation != UNKNOWN_TRANSACTIONISOLATION) 
-                    && (conn.getTransactionIsolation() != 
+            if ((_defaultTransactionIsolation != UNKNOWN_TRANSACTIONISOLATION)
+                    && (conn.getTransactionIsolation() !=
                     _defaultTransactionIsolation)) {
                 conn.setTransactionIsolation(_defaultTransactionIsolation);
             }
-            if ((_defaultReadOnly != null) && 
+            if ((_defaultReadOnly != null) &&
                     (conn.isReadOnly() != _defaultReadOnly.booleanValue())) {
                 conn.setReadOnly(_defaultReadOnly.booleanValue());
             }



Mime
View raw message