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

jimin pushed a commit to branch 2.x
in repository https://gitbox.apache.org/repos/asf/incubator-seata.git


The following commit(s) were added to refs/heads/2.x by this push:
     new c3e9454573 bugfix: fix businessActionContext not compatible with 
io.seata (#6555)
c3e9454573 is described below

commit c3e94545737ebf71a514542da3e437a18ec063d7
Author: funkye <[email protected]>
AuthorDate: Fri May 17 00:23:24 2024 +0800

    bugfix: fix businessActionContext not compatible with io.seata (#6555)
---
 changes/en-us/2.x.md                               |  3 ++
 changes/zh-cn/2.x.md                               |  4 +-
 .../java/io/seata/rm/tcc/TCCResourceManager.java   | 52 ++++++++++++++++++++++
 .../services/io.seata.core.model.ResourceManager   |  3 +-
 .../rm/tcc/api/BusinessActionContextUtil.java      | 11 -----
 .../apache/seata/rm/tcc/TCCResourceManager.java    | 18 ++++++--
 6 files changed, 75 insertions(+), 16 deletions(-)

diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md
index abfc6dcc1b..b135bbb390 100644
--- a/changes/en-us/2.x.md
+++ b/changes/en-us/2.x.md
@@ -40,6 +40,9 @@ Add changes here for all PR submitted to the 2.x branch.
 - [[#6493](https://github.com/apache/incubator-seata/pull/6493)] fix 
SQLServer-related SQL error in seata server when using database of SQLServer
 - [[#6497](https://github.com/apache/incubator-seata/pull/6497)] fix tcc 
properties class when autoconfigure
 - [[#6554](https://github.com/apache/incubator-seata/pull/6554)] fix unfixed 
serializer
+- [[#6555](https://github.com/apache/incubator-seata/pull/6555)] 
businessActionContext is compatible with io seata
+- [[#6553](https://github.com/apache/incubator-seata/pull/6553)] fix saga 
"cannot matching status"
+
 
 ### optimize:
 - [[#6031](https://github.com/apache/incubator-seata/pull/6031)] add a check 
for the existence of the undolog table
diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md
index 70d5399583..8df775e61a 100644
--- a/changes/zh-cn/2.x.md
+++ b/changes/zh-cn/2.x.md
@@ -40,7 +40,9 @@
 - [[#6493](https://github.com/apache/incubator-seata/pull/6493)] 
修复当使用数据库为SQLServer时seata server的SQL报错
 - [[#6497](https://github.com/apache/incubator-seata/pull/6497)] 修复自动装配时的seata 
tcc 配置类
 - [[#6554](https://github.com/apache/incubator-seata/pull/6554)] 
修复序列化器不固定使用对应配置序列化器的问题
-- 
+- [[#6555](https://github.com/apache/incubator-seata/pull/6555)] 
修复businessActionContext对io seata包的不兼容
+- [[#6553](https://github.com/apache/incubator-seata/pull/6553)] 修复执行完 
'ServiceTask' 后无法应用任何评估器的问题
+
 ### optimize:
 - [[#6031](https://github.com/apache/incubator-seata/pull/6031)] 
添加undo_log表的存在性校验
 - [[#6089](https://github.com/apache/incubator-seata/pull/6089)] 
修改RaftServerFactory语义并删除不必要的单例构建
diff --git a/compatible/src/main/java/io/seata/rm/tcc/TCCResourceManager.java 
b/compatible/src/main/java/io/seata/rm/tcc/TCCResourceManager.java
new file mode 100644
index 0000000000..0289e0fbe4
--- /dev/null
+++ b/compatible/src/main/java/io/seata/rm/tcc/TCCResourceManager.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.seata.rm.tcc;
+
+import org.apache.seata.rm.tcc.api.BusinessActionContext;
+
+/**
+ * TCC resource manager
+ *
+ */
+public class TCCResourceManager extends 
org.apache.seata.rm.tcc.TCCResourceManager {
+
+    @Override
+    protected Object[] getTwoPhaseMethodParams(String[] keys, Class<?>[] 
argsClasses,
+        BusinessActionContext businessActionContext) {
+        Object[] args = new Object[argsClasses.length];
+        for (int i = 0; i < argsClasses.length; i++) {
+            if (argsClasses[i].equals(BusinessActionContext.class)) {
+                args[i] = businessActionContext;
+            } else if 
(argsClasses[i].equals(io.seata.rm.tcc.api.BusinessActionContext.class)) {
+                io.seata.rm.tcc.api.BusinessActionContext 
oldBusinessActionContext =
+                    new io.seata.rm.tcc.api.BusinessActionContext();
+                
oldBusinessActionContext.setUpdated(businessActionContext.getUpdated());
+                
oldBusinessActionContext.setXid(businessActionContext.getXid());
+                
oldBusinessActionContext.setActionContext(businessActionContext.getActionContext());
+                
oldBusinessActionContext.setActionName(businessActionContext.getActionName());
+                
oldBusinessActionContext.setBranchId(businessActionContext.getBranchId());
+                
oldBusinessActionContext.setBranchType(businessActionContext.getBranchType());
+                
oldBusinessActionContext.setDelayReport(businessActionContext.getDelayReport());
+                args[i] = oldBusinessActionContext;
+            } else {
+                args[i] = businessActionContext.getActionContext(keys[i], 
argsClasses[i]);
+            }
+        }
+        return args;
+    }
+
+}
diff --git 
a/compatible/src/main/resources/META-INF/services/io.seata.core.model.ResourceManager
 
b/compatible/src/main/resources/META-INF/services/io.seata.core.model.ResourceManager
index 4ec5cba1d3..1ff3f1997e 100644
--- 
a/compatible/src/main/resources/META-INF/services/io.seata.core.model.ResourceManager
+++ 
b/compatible/src/main/resources/META-INF/services/io.seata.core.model.ResourceManager
@@ -1 +1,2 @@
-io.seata.saga.rm.SagaResourceManager
\ No newline at end of file
+io.seata.saga.rm.SagaResourceManager
+io.seata.rm.tcc.TCCResourceManager
\ No newline at end of file
diff --git 
a/integration-tx-api/src/main/java/org/apache/seata/rm/tcc/api/BusinessActionContextUtil.java
 
b/integration-tx-api/src/main/java/org/apache/seata/rm/tcc/api/BusinessActionContextUtil.java
index 4691fc1eef..67d48c233e 100644
--- 
a/integration-tx-api/src/main/java/org/apache/seata/rm/tcc/api/BusinessActionContextUtil.java
+++ 
b/integration-tx-api/src/main/java/org/apache/seata/rm/tcc/api/BusinessActionContextUtil.java
@@ -162,15 +162,4 @@ public final class BusinessActionContextUtil {
         return businessActionContext;
     }
 
-    public static Object[] getTwoPhaseMethodParams(String[] keys, Class<?>[] 
argsClasses, BusinessActionContext businessActionContext) {
-        Object[] args = new Object[argsClasses.length];
-        for (int i = 0; i < argsClasses.length; i++) {
-            if (argsClasses[i].equals(BusinessActionContext.class)) {
-                args[i] = businessActionContext;
-            } else {
-                args[i] = businessActionContext.getActionContext(keys[i], 
argsClasses[i]);
-            }
-        }
-        return args;
-    }
 }
diff --git a/tcc/src/main/java/org/apache/seata/rm/tcc/TCCResourceManager.java 
b/tcc/src/main/java/org/apache/seata/rm/tcc/TCCResourceManager.java
index c19f08604c..2e7286da1f 100644
--- a/tcc/src/main/java/org/apache/seata/rm/tcc/TCCResourceManager.java
+++ b/tcc/src/main/java/org/apache/seata/rm/tcc/TCCResourceManager.java
@@ -213,10 +213,10 @@ public class TCCResourceManager extends 
AbstractResourceManager {
      * @param businessActionContext businessActionContext
      * @return args
      */
-    private Object[] getTwoPhaseCommitArgs(TCCResource tccResource, 
BusinessActionContext businessActionContext) {
+    protected Object[] getTwoPhaseCommitArgs(TCCResource tccResource, 
BusinessActionContext businessActionContext) {
         String[] keys = tccResource.getPhaseTwoCommitKeys();
         Class<?>[] argsCommitClasses = tccResource.getCommitArgsClasses();
-        return BusinessActionContextUtil.getTwoPhaseMethodParams(keys, 
argsCommitClasses, businessActionContext);
+        return getTwoPhaseMethodParams(keys, argsCommitClasses, 
businessActionContext);
     }
 
     /**
@@ -228,7 +228,19 @@ public class TCCResourceManager extends 
AbstractResourceManager {
     private Object[] getTwoPhaseRollbackArgs(TCCResource tccResource, 
BusinessActionContext businessActionContext) {
         String[] keys = tccResource.getPhaseTwoRollbackKeys();
         Class<?>[] argsRollbackClasses = tccResource.getRollbackArgsClasses();
-        return BusinessActionContextUtil.getTwoPhaseMethodParams(keys, 
argsRollbackClasses, businessActionContext);
+        return getTwoPhaseMethodParams(keys, argsRollbackClasses, 
businessActionContext);
+    }
+
+    protected Object[] getTwoPhaseMethodParams(String[] keys, Class<?>[] 
argsClasses, BusinessActionContext businessActionContext) {
+        Object[] args = new Object[argsClasses.length];
+        for (int i = 0; i < argsClasses.length; i++) {
+            if (argsClasses[i].equals(BusinessActionContext.class)) {
+                args[i] = businessActionContext;
+            } else {
+                args[i] = businessActionContext.getActionContext(keys[i], 
argsClasses[i]);
+            }
+        }
+        return args;
     }
 
     @Override


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to