This is an automated email from the ASF dual-hosted git repository.

tuichenchuxin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new ebca116899a Add map xa exception in SingleXAResource (#29980)
ebca116899a is described below

commit ebca116899afd70dd50a8843da1e3a160dd6af00
Author: ZhangCheng <[email protected]>
AuthorDate: Tue Feb 6 18:11:08 2024 +0800

    Add map xa exception in SingleXAResource (#29980)
---
 .../transaction/xa/spi/SingleXAResource.java       | 46 ++++++++++++++++++----
 1 file changed, 39 insertions(+), 7 deletions(-)

diff --git 
a/kernel/transaction/type/xa/spi/src/main/java/org/apache/shardingsphere/transaction/xa/spi/SingleXAResource.java
 
b/kernel/transaction/type/xa/spi/src/main/java/org/apache/shardingsphere/transaction/xa/spi/SingleXAResource.java
index e026afa3ea2..4375cbcf057 100644
--- 
a/kernel/transaction/type/xa/spi/src/main/java/org/apache/shardingsphere/transaction/xa/spi/SingleXAResource.java
+++ 
b/kernel/transaction/type/xa/spi/src/main/java/org/apache/shardingsphere/transaction/xa/spi/SingleXAResource.java
@@ -37,17 +37,29 @@ public final class SingleXAResource implements XAResource {
     
     @Override
     public void commit(final Xid xid, final boolean onePhase) throws 
XAException {
-        delegate.commit(xid, onePhase);
+        try {
+            delegate.commit(xid, onePhase);
+        } catch (final XAException ex) {
+            throw mapXAException(ex);
+        }
     }
     
     @Override
     public void end(final Xid xid, final int flags) throws XAException {
-        delegate.end(xid, flags);
+        try {
+            delegate.end(xid, flags);
+        } catch (final XAException ex) {
+            throw mapXAException(ex);
+        }
     }
     
     @Override
     public void forget(final Xid xid) throws XAException {
-        delegate.forget(xid);
+        try {
+            delegate.forget(xid);
+        } catch (final XAException ex) {
+            throw mapXAException(ex);
+        }
     }
     
     @Override
@@ -63,17 +75,29 @@ public final class SingleXAResource implements XAResource {
     
     @Override
     public int prepare(final Xid xid) throws XAException {
-        return delegate.prepare(xid);
+        try {
+            return delegate.prepare(xid);
+        } catch (final XAException ex) {
+            throw mapXAException(ex);
+        }
     }
     
     @Override
     public Xid[] recover(final int flags) throws XAException {
-        return delegate.recover(flags);
+        try {
+            return delegate.recover(flags);
+        } catch (final XAException ex) {
+            throw mapXAException(ex);
+        }
     }
     
     @Override
     public void rollback(final Xid xid) throws XAException {
-        delegate.rollback(xid);
+        try {
+            delegate.rollback(xid);
+        } catch (final XAException ex) {
+            throw mapXAException(ex);
+        }
     }
     
     @Override
@@ -83,6 +107,14 @@ public final class SingleXAResource implements XAResource {
     
     @Override
     public void start(final Xid xid, final int flags) throws XAException {
-        delegate.start(xid, flags);
+        try {
+            delegate.start(xid, flags);
+        } catch (final XAException ex) {
+            throw mapXAException(ex);
+        }
+    }
+    
+    private XAException mapXAException(final XAException exception) throws 
XAException {
+        return exception;
     }
 }

Reply via email to