This is an automated email from the ASF dual-hosted git repository.
jimin pushed a commit to branch 2.1.0
in repository https://gitbox.apache.org/repos/asf/incubator-seata.git
The following commit(s) were added to refs/heads/2.1.0 by this push:
new 611395a174 sync 2.x to 2.1.0 (#6557)
611395a174 is described below
commit 611395a174434ad3abc40c911214227852608b80
Author: jimin <[email protected]>
AuthorDate: Fri May 17 11:06:33 2024 +0800
sync 2.x to 2.1.0 (#6557)
---
build/pom.xml | 1 +
changes/en-us/2.x.md | 4 ++
changes/zh-cn/2.x.md | 3 ++
.../java/io/seata/rm/tcc/TCCResourceManager.java | 52 ++++++++++++++++++++++
.../services/io.seata.core.model.ResourceManager | 3 +-
.../seata/core/protocol/ProtocolConstants.java | 2 +-
.../seata/core/rpc/netty/v1/ProtocolV1Decoder.java | 6 +--
.../core/serializer/SerializerServiceLoader.java | 15 ++++---
dependencies/pom.xml | 10 +++++
discovery/seata-discovery-etcd3/pom.xml | 5 +++
.../rm/tcc/api/BusinessActionContextUtil.java | 11 -----
integration/grpc/pom.xml | 6 ++-
.../ServiceTaskHandlerInterceptor.java | 4 +-
.../apache/seata/rm/tcc/TCCResourceManager.java | 18 ++++++--
14 files changed, 113 insertions(+), 27 deletions(-)
diff --git a/build/pom.xml b/build/pom.xml
index 59b4273396..04a19faf6c 100644
--- a/build/pom.xml
+++ b/build/pom.xml
@@ -24,6 +24,7 @@
<groupId>org.apache</groupId>
<artifactId>apache</artifactId>
<version>19</version>
+ <relativePath/>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.seata</groupId>
diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md
index 8e3aa477d0..b135bbb390 100644
--- a/changes/en-us/2.x.md
+++ b/changes/en-us/2.x.md
@@ -39,6 +39,10 @@ Add changes here for all PR submitted to the 2.x branch.
- [[#6496](https://github.com/apache/incubator-seata/pull/6496)] fix XA did
not rollback but close when executing a long-running SQL(or deadlock SQL)
- [[#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 2e6b21fac3..8df775e61a 100644
--- a/changes/zh-cn/2.x.md
+++ b/changes/zh-cn/2.x.md
@@ -39,6 +39,9 @@
- [[#6496](https://github.com/apache/incubator-seata/pull/6496)]
修复XA执行长时间SQL(或死锁SQL)没有完成回滚就释放连接
- [[#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表的存在性校验
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/core/src/main/java/org/apache/seata/core/protocol/ProtocolConstants.java
b/core/src/main/java/org/apache/seata/core/protocol/ProtocolConstants.java
index 98039180c7..7848b4bb66 100644
--- a/core/src/main/java/org/apache/seata/core/protocol/ProtocolConstants.java
+++ b/core/src/main/java/org/apache/seata/core/protocol/ProtocolConstants.java
@@ -76,7 +76,7 @@ public interface ProtocolConstants {
*
* @see SerializerType#SEATA
*/
- byte CONFIGURED_CODEC =
SerializerServiceLoader.getSupportedSerializers().iterator().next().getCode();
+ byte CONFIGURED_CODEC =
SerializerServiceLoader.getDefaultSerializerType().getCode();
/**
* Configured compressor by user, default is NONE
diff --git
a/core/src/main/java/org/apache/seata/core/rpc/netty/v1/ProtocolV1Decoder.java
b/core/src/main/java/org/apache/seata/core/rpc/netty/v1/ProtocolV1Decoder.java
index 77e758af65..68a12b52d3 100644
---
a/core/src/main/java/org/apache/seata/core/rpc/netty/v1/ProtocolV1Decoder.java
+++
b/core/src/main/java/org/apache/seata/core/rpc/netty/v1/ProtocolV1Decoder.java
@@ -16,8 +16,8 @@
*/
package org.apache.seata.core.rpc.netty.v1;
+import java.util.List;
import java.util.Map;
-import java.util.Set;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
@@ -64,7 +64,7 @@ public class ProtocolV1Decoder extends
LengthFieldBasedFrameDecoder {
private static final Logger LOGGER =
LoggerFactory.getLogger(ProtocolV1Decoder.class);
- private final Set<SerializerType> supportDeSerializerTypes;
+ private final List<SerializerType> supportDeSerializerTypes;
public ProtocolV1Decoder() {
@@ -155,7 +155,7 @@ public class ProtocolV1Decoder extends
LengthFieldBasedFrameDecoder {
Serializer serializer =
SerializerServiceLoader.load(protocolType);
rpcMessage.setBody(serializer.deserialize(bs));
} else {
- throw new IllegalArgumentException("SerializerType not
match");
+ throw new IllegalArgumentException("SerializerType not
match: " + protocolType.name());
}
}
}
diff --git
a/core/src/main/java/org/apache/seata/core/serializer/SerializerServiceLoader.java
b/core/src/main/java/org/apache/seata/core/serializer/SerializerServiceLoader.java
index f824c09a8c..a6f54ffe3d 100644
---
a/core/src/main/java/org/apache/seata/core/serializer/SerializerServiceLoader.java
+++
b/core/src/main/java/org/apache/seata/core/serializer/SerializerServiceLoader.java
@@ -16,9 +16,9 @@
*/
package org.apache.seata.core.serializer;
+import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
+import java.util.List;
import java.util.stream.Collectors;
import org.apache.seata.common.loader.EnhancedServiceLoader;
@@ -73,8 +73,8 @@ public final class SerializerServiceLoader {
return EnhancedServiceLoader.load(Serializer.class, type.name());
}
- public static Set<SerializerType> getSupportedSerializers() {
- Set<SerializerType> supportedSerializers = new HashSet<>();
+ public static List<SerializerType> getSupportedSerializers() {
+ List<SerializerType> supportedSerializers = new ArrayList<>();
String defaultSupportSerializers =
Arrays.stream(DEFAULT_SERIALIZER_TYPE).map(SerializerType::name).collect(Collectors.joining(SPLIT_CHAR));
String serializerNames =
CONFIG.getConfig(ConfigurationKeys.SERIALIZE_FOR_RPC,
defaultSupportSerializers);
String[] serializerNameArray = serializerNames.split(SPLIT_CHAR);
@@ -86,6 +86,11 @@ public final class SerializerServiceLoader {
LOGGER.warn("Invalid serializer name: " + serializerName);
}
}
- return supportedSerializers;
+ return
supportedSerializers.stream().distinct().collect(Collectors.toList());
}
+
+ public static SerializerType getDefaultSerializerType() {
+ return getSupportedSerializers().get(0);
+ }
+
}
diff --git a/dependencies/pom.xml b/dependencies/pom.xml
index 48b73bccbc..50d0bc19b1 100644
--- a/dependencies/pom.xml
+++ b/dependencies/pom.xml
@@ -559,6 +559,16 @@
<version>${grpc.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-core</artifactId>
+ <version>${grpc.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-api</artifactId>
+ <version>${grpc.version}</version>
+ </dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
diff --git a/discovery/seata-discovery-etcd3/pom.xml
b/discovery/seata-discovery-etcd3/pom.xml
index 9eee507f1c..53a68488c5 100644
--- a/discovery/seata-discovery-etcd3/pom.xml
+++ b/discovery/seata-discovery-etcd3/pom.xml
@@ -39,6 +39,11 @@
<groupId>io.etcd</groupId>
<artifactId>jetcd-core</artifactId>
</dependency>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
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/integration/grpc/pom.xml b/integration/grpc/pom.xml
index 77769bd637..cf42b481af 100644
--- a/integration/grpc/pom.xml
+++ b/integration/grpc/pom.xml
@@ -60,7 +60,11 @@
<artifactId>grpc-stub</artifactId>
<scope>provided</scope>
</dependency>
-
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-core</artifactId>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-testing</artifactId>
diff --git
a/saga/seata-saga-engine/src/main/java/org/apache/seata/saga/engine/pcext/interceptors/ServiceTaskHandlerInterceptor.java
b/saga/seata-saga-engine/src/main/java/org/apache/seata/saga/engine/pcext/interceptors/ServiceTaskHandlerInterceptor.java
index 03a8c238a3..1cee6d2ccf 100644
---
a/saga/seata-saga-engine/src/main/java/org/apache/seata/saga/engine/pcext/interceptors/ServiceTaskHandlerInterceptor.java
+++
b/saga/seata-saga-engine/src/main/java/org/apache/seata/saga/engine/pcext/interceptors/ServiceTaskHandlerInterceptor.java
@@ -337,9 +337,9 @@ public class ServiceTaskHandlerInterceptor implements
StateHandlerInterceptor {
Object elContext;
Class<? extends Expression> expressionClass =
evaluator.getClass();
- if
(expressionClass.isAssignableFrom(ExceptionMatchExpression.class)) {
+ if
(ExceptionMatchExpression.class.isAssignableFrom(expressionClass)) {
elContext =
context.getVariable(DomainConstants.VAR_NAME_CURRENT_EXCEPTION);
- } else if
(expressionClass.isAssignableFrom(ELExpression.class)) {
+ } else if
(ELExpression.class.isAssignableFrom(expressionClass)) {
elContext =
context.getVariable(DomainConstants.VAR_NAME_OUTPUT_PARAMS);
} else {
elContext = context.getVariables();
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]