commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1564086 - in /commons/proper/dbcp/branches/DBCP_1_5_x_BRANCH/src: changes/changes.xml main/java/org/apache/commons/dbcp/managed/LocalXAConnectionFactory.java
Date Mon, 03 Feb 2014 21:55:38 GMT
Author: markt
Date: Mon Feb  3 21:55:38 2014
New Revision: 1564086

URL: http://svn.apache.org/r1564086
Log:
Fix DBCP-383
Avoid NullPointerException and throw an XAException if an attempt is made to commit the current
transaction for a connection when no transaction has been started.

Modified:
    commons/proper/dbcp/branches/DBCP_1_5_x_BRANCH/src/changes/changes.xml
    commons/proper/dbcp/branches/DBCP_1_5_x_BRANCH/src/main/java/org/apache/commons/dbcp/managed/LocalXAConnectionFactory.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=1564086&r1=1564085&r2=1564086&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 Feb  3 21:55:38
2014
@@ -94,6 +94,11 @@ The <action> type attribute can be add,u
       <action dev="markt" issue="DBCP-398" type="fix">
         Clarify Jaavdoc for isClosed() method of PoolableConnection.
       </action>
+      <action dev="markt" issue="DBCP-383" type="fix">
+        Avoid NullPointerException and throw an XAException if an attempt is
+        made to commit the current transaction for a connection when no
+        transaction has been started.
+      </action>
     </release>
     <release version="1.4.1" date="TBD" description="TBD">
       <action dev="psteitz" issue="DBCP-367" type="fix" due-to="Ken Tatsushita">

Modified: commons/proper/dbcp/branches/DBCP_1_5_x_BRANCH/src/main/java/org/apache/commons/dbcp/managed/LocalXAConnectionFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/branches/DBCP_1_5_x_BRANCH/src/main/java/org/apache/commons/dbcp/managed/LocalXAConnectionFactory.java?rev=1564086&r1=1564085&r2=1564086&view=diff
==============================================================================
--- commons/proper/dbcp/branches/DBCP_1_5_x_BRANCH/src/main/java/org/apache/commons/dbcp/managed/LocalXAConnectionFactory.java
(original)
+++ commons/proper/dbcp/branches/DBCP_1_5_x_BRANCH/src/main/java/org/apache/commons/dbcp/managed/LocalXAConnectionFactory.java
Mon Feb  3 21:55:38 2014
@@ -197,8 +197,16 @@ public class LocalXAConnectionFactory im
          * @throws XAException if connection.commit() throws a SQLException
          */
         public synchronized void commit(Xid xid, boolean flag) throws XAException {
-            if (xid == null) throw new NullPointerException("xid is null");
-            if (!this.currentXid.equals(xid)) throw new XAException("Invalid Xid: expected
" + this.currentXid + ", but was " + xid);
+            if (xid == null) {
+                throw new NullPointerException("xid is null");
+            }
+            if (this.currentXid == null) {
+                throw new XAException("There is no current transaction");
+            }
+            if (!this.currentXid.equals(xid)) {
+                throw new XAException("Invalid Xid: expected " +
+                        this.currentXid + ", but was " + xid);
+            }
 
             try {
                 // make sure the connection isn't already closed



Mime
View raw message