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 30ca366df3 bugfix: unfixed serializer (#6554)
30ca366df3 is described below
commit 30ca366df3cfd23d45edc8773bf7902ec57811f7
Author: funkye <[email protected]>
AuthorDate: Thu May 16 23:00:12 2024 +0800
bugfix: unfixed serializer (#6554)
---
build/pom.xml | 1 +
changes/en-us/2.x.md | 1 +
changes/zh-cn/2.x.md | 3 ++-
.../org/apache/seata/core/protocol/ProtocolConstants.java | 2 +-
.../apache/seata/core/rpc/netty/v1/ProtocolV1Decoder.java | 6 +++---
.../seata/core/serializer/SerializerServiceLoader.java | 15 ++++++++++-----
dependencies/pom.xml | 10 ++++++++++
discovery/seata-discovery-etcd3/pom.xml | 5 +++++
integration/grpc/pom.xml | 6 +++++-
9 files changed, 38 insertions(+), 11 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..abfc6dcc1b 100644
--- a/changes/en-us/2.x.md
+++ b/changes/en-us/2.x.md
@@ -39,6 +39,7 @@ 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
### 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..70d5399583 100644
--- a/changes/zh-cn/2.x.md
+++ b/changes/zh-cn/2.x.md
@@ -39,7 +39,8 @@
- [[#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)]
修复序列化器不固定使用对应配置序列化器的问题
+-
### 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/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/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>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]