jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dpfis...@apache.org
Subject svn commit: r159360 - incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/XASessionImpl.java
Date Tue, 29 Mar 2005 09:45:24 GMT
Author: dpfister
Date: Tue Mar 29 01:45:23 2005
New Revision: 159360

URL: http://svn.apache.org/viewcvs?view=rev&rev=159360
Log:
Extended XAException allowing a base exception to be passed. Removes
the ugly stack trace on the console when performing XATest.testAddReference()
which causes an intended RollbackException.

Modified:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/XASessionImpl.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/XASessionImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/XASessionImpl.java?view=diff&r1=159359&r2=159360
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/XASessionImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/XASessionImpl.java Tue
Mar 29 01:45:23 2005
@@ -253,8 +253,7 @@
         try {
             wsp.getItemStateManager().commit(tx);
         } catch (TransactionException e) {
-            log.error("Unable to commit transaction.", e);
-            throw new XAException(XAException.XA_RBOTHER);
+            throw new ExtendedXAException(XAException.XA_RBOTHER, e);
         }
     }
 
@@ -365,5 +364,28 @@
      */
     private static boolean stringsEqual(String s1, String s2) {
         return s1 == null ? s2 == null : s1.equals(s2);
+    }
+
+    /**
+     * Internal XAException derived class that allows passing a base exception
+     * in its constructor.
+     */
+    static class ExtendedXAException extends XAException {
+
+        /**
+         * Create an XAException with a given error code and a root cause.
+         * @param errcode The error code identifying the exception.
+         * @param cause The cause (which is saved for later retrieval by the
+         *              {@link #getCause()} method).  (A <tt>null</tt> value
is
+         *              permitted, and indicates that the cause is nonexistent
+         *              or unknown.)
+         */
+        public ExtendedXAException(int errcode, Throwable cause) {
+            super(errcode);
+
+            if (cause != null) {
+                initCause(cause);
+            }
+        }
     }
 }



Mime
View raw message