commons-commits mailing list archives

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

URL: http://svn.apache.org/r1564084
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/trunk/src/changes/changes.xml
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/LocalXAConnectionFactory.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=1564084&r1=1564083&r2=1564084&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/changes/changes.xml (original)
+++ commons/proper/dbcp/trunk/src/changes/changes.xml Mon Feb  3 21:55:11 2014
@@ -152,6 +152,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-334" type="update" due-to="Alberto Mozzone">

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/LocalXAConnectionFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/LocalXAConnectionFactory.java?rev=1564084&r1=1564083&r2=1564084&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/LocalXAConnectionFactory.java
(original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/LocalXAConnectionFactory.java
Mon Feb  3 21:55:11 2014
@@ -203,8 +203,16 @@ public class LocalXAConnectionFactory im
          */
         @Override
         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