This is an automated email from the ASF dual-hosted git repository.
jianbin 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 4b281489f1 optimize: replace fury with fory (#7885)
4b281489f1 is described below
commit 4b281489f1684ae73504db9fa0b0a82eea470ef1
Author: jimin <[email protected]>
AuthorDate: Sat Dec 27 20:44:44 2025 +0800
optimize: replace fury with fory (#7885)
---
all/pom.xml | 5 -
changes/en-us/2.x.md | 1 +
changes/zh-cn/2.x.md | 1 +
.../core/serializer/SerializerServiceLoader.java | 47 +++++-
dependencies/pom.xml | 10 +-
distribution/LICENSE-server | 2 +-
rm-datasource/pom.xml | 6 -
.../rm/datasource/undo/UndoLogParserFactory.java | 35 +++-
.../datasource/undo/parser/FuryUndoLogParser.java | 68 --------
...g.apache.seata.rm.datasource.undo.UndoLogParser | 1 -
.../undo/parser/FuryUndoLogParserTest.java | 35 ----
serializer/pom.xml | 1 -
serializer/seata-serializer-all/pom.xml | 5 -
serializer/seata-serializer-fury/pom.xml | 54 -------
.../serializer/fury/DynamicSerializerFactory.java | 59 -------
.../serializer/fury/ForySerializerDelegate.java | 35 ----
.../seata/serializer/fury/FurySerializer.java | 42 -----
.../serializer/fury/ThreadSafeForyDelegate.java | 59 -------
.../serializer/fury/ThreadSafeFuryDelegate.java | 60 -------
.../org.apache.seata.core.serializer.Serializer | 17 --
.../seata/serializer/fury/FurySerializerTest.java | 177 ---------------------
.../java/org/seata/test/TestUnSafeSerializer.java | 26 ---
22 files changed, 76 insertions(+), 670 deletions(-)
diff --git a/all/pom.xml b/all/pom.xml
index bf608490e3..883f641275 100644
--- a/all/pom.xml
+++ b/all/pom.xml
@@ -262,11 +262,6 @@
<artifactId>seata-hsf</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>org.apache.seata</groupId>
- <artifactId>seata-serializer-fury</artifactId>
- <version>${project.version}</version>
- </dependency>
<dependency>
<groupId>org.apache.seata</groupId>
<artifactId>seata-serializer-fory</artifactId>
diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md
index 303d575053..ec61b85f88 100644
--- a/changes/en-us/2.x.md
+++ b/changes/en-us/2.x.md
@@ -103,6 +103,7 @@ Add changes here for all PR submitted to the 2.x branch.
- [[#7864](https://github.com/apache/incubator-seata/pull/7864)] automatically
skip the compilation of console and namingserver modules in JDK<25
- [[#7868](https://github.com/apache/incubator-seata/pull/7868)] change
build_arm64-binary CI to JDK25 Version and runs on ubuntu-24.04-arm
- [[#7873](https://github.com/apache/incubator-seata/pull/7873)] upgrade
jacoco plugin version from 0.8.7 to 0.8.14 in order to adapt JDK25
+- [[#7885](https://github.com/apache/incubator-seata/pull/7885)] replace fury
with fory
- [[#7884](https://github.com/apache/incubator-seata/pull/7884)] upgrade
tomcat-embed-core version to 11.0.10
diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md
index 5fa00db58a..71ec918f1b 100644
--- a/changes/zh-cn/2.x.md
+++ b/changes/zh-cn/2.x.md
@@ -102,6 +102,7 @@
- [[#7864](https://github.com/apache/incubator-seata/pull/7864)]
自动跳过JDK<25环境下的console和namingserver模块编译
- [[#7868](https://github.com/apache/incubator-seata/pull/7868)]
将build_arm64-binary的CI更改为JDK25版本,并运行于ubuntu-24.04-arm
- [[#7873](https://github.com/apache/incubator-seata/pull/7873)]
将Jacoco插件版本从0.8.7升级到0.8.14以适配JDK25
+- [[#7885](https://github.com/apache/incubator-seata/pull/7885)] 替换 fury 至 fory
- [[#7884](https://github.com/apache/incubator-seata/pull/7884)] 将
tomcat-embed-core 版本升级到 11.0.10
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 8ce367cabd..f1923b3cd7 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
@@ -30,6 +30,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.stream.Collectors;
import static org.apache.seata.core.serializer.SerializerType.FASTJSON2;
@@ -53,8 +54,14 @@ public final class SerializerServiceLoader {
private static final Map<String, Serializer> SERIALIZER_MAP = new
HashMap<>();
+ private static final Map<String, String> SERIALIZER_ALIAS_MAP = new
HashMap<>();
+
private static final String SPLIT_CHAR = ",";
+ static {
+ SERIALIZER_ALIAS_MAP.put("fury", "fory");
+ }
+
private SerializerServiceLoader() {}
private static final String PROTOBUF_SERIALIZER_CLASS_NAME =
@@ -76,15 +83,22 @@ public final class SerializerServiceLoader {
+ "Please manually reference
'org.apache.seata:seata-serializer-protobuf' dependency.");
}
- String key = serializerKey(type, version);
- Serializer serializer = SERIALIZER_MAP.get(key);
+ String serializerName = serializerKey(type, version);
+ String resolvedSerializerName = resolveSerializerName(serializerName);
+ if (!Objects.equals(serializerName, resolvedSerializerName)) {
+ LOGGER.info(
+ "Since {} is no longer maintained, This serialization
extension has been replaced with {}.",
+ serializerName,
+ resolvedSerializerName);
+ }
+ Serializer serializer = SERIALIZER_MAP.get(resolvedSerializerName);
if (serializer == null) {
if (type == SerializerType.SEATA) {
serializer = EnhancedServiceLoader.load(Serializer.class,
type.name(), new Object[] {version});
} else {
- serializer = EnhancedServiceLoader.load(Serializer.class,
type.name());
+ serializer = EnhancedServiceLoader.load(Serializer.class,
resolvedSerializerName);
}
- SERIALIZER_MAP.put(key, serializer);
+ SERIALIZER_MAP.put(serializerName, serializer);
}
return serializer;
}
@@ -102,12 +116,19 @@ public final class SerializerServiceLoader {
+ "Please manually reference
'org.apache.seata:seata-serializer-protobuf' dependency.");
}
- String key = type.name();
- Serializer serializer = SERIALIZER_MAP.get(key);
+ String serializerName = type.name();
+ String resolvedSerializerName = resolveSerializerName(serializerName);
+ if (!Objects.equals(serializerName, resolvedSerializerName)) {
+ LOGGER.info(
+ "Since {} is no longer maintained, This serialization
extension has been replaced with {}.",
+ serializerName,
+ resolvedSerializerName);
+ }
+ Serializer serializer = SERIALIZER_MAP.get(resolvedSerializerName);
if (serializer == null) {
- serializer = EnhancedServiceLoader.load(Serializer.class,
type.name());
+ serializer = EnhancedServiceLoader.load(Serializer.class,
resolvedSerializerName);
- SERIALIZER_MAP.put(key, serializer);
+ SERIALIZER_MAP.put(serializerName, serializer);
}
return serializer;
}
@@ -140,4 +161,14 @@ public final class SerializerServiceLoader {
public static SerializerType getDefaultSerializerType() {
return getSupportedSerializers().get(0);
}
+
+ /**
+ * Resolve serializer name from alias mapping
+ *
+ * @param serializerName the original serializer name
+ * @return the resolved serializer name
+ */
+ private static String resolveSerializerName(String serializerName) {
+ return SERIALIZER_ALIAS_MAP.getOrDefault(serializerName.toLowerCase(),
serializerName);
+ }
}
diff --git a/dependencies/pom.xml b/dependencies/pom.xml
index 8a26a838e4..22a186c62d 100644
--- a/dependencies/pom.xml
+++ b/dependencies/pom.xml
@@ -143,8 +143,7 @@
<mockwebserver-version>4.12.0</mockwebserver-version>
<native-lib-loader.version>2.4.0</native-lib-loader.version>
- <!-- for fury -->
- <fury.version>0.10.3</fury.version>
+ <!-- for fory -->
<fory.version>0.12.3</fory.version>
</properties>
@@ -895,12 +894,7 @@
<version>${rocketmq-version}</version>
</dependency>
- <!-- Fury Serialize -->
- <dependency>
- <groupId>org.apache.fury</groupId>
- <artifactId>fury-core</artifactId>
- <version>${fury.version}</version>
- </dependency>
+ <!-- Fory Serialize -->
<dependency>
<groupId>org.apache.fory</groupId>
<artifactId>fory-core</artifactId>
diff --git a/distribution/LICENSE-server b/distribution/LICENSE-server
index a1f49df4ec..117328a955 100644
--- a/distribution/LICENSE-server
+++ b/distribution/LICENSE-server
@@ -361,7 +361,7 @@ Apache-2.0 licenses
org.springframework:spring-webmvc 5.3.39 Apache-2.0
org.springframework:spring-test 5.3.39 Apache-2.0
org.apache.curator:curator-client 5.1.0 Apache-2.0
- org.apache.fury:fury-core 0.8.0 Apache-2.0
+ org.apache.fury:fury-core 0.12.3 Apache-2.0
org.apache.tomcat:tomcat-annotations-api 9.0.83 Apache-2.0
org.apache.zookeeper:zookeeper 3.7.2 Apache-2.0
org.apache.zookeeper:zookeeper-jute 3.7.2 Apache-2.0
diff --git a/rm-datasource/pom.xml b/rm-datasource/pom.xml
index 9672700b81..9ae40fcdf0 100644
--- a/rm-datasource/pom.xml
+++ b/rm-datasource/pom.xml
@@ -143,12 +143,6 @@
<artifactId>DmJdbcDriver18</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.fury</groupId>
- <artifactId>fury-core</artifactId>
- <scope>provided</scope>
- <optional>true</optional>
- </dependency>
<dependency>
<groupId>org.apache.fory</groupId>
<artifactId>fory-core</artifactId>
diff --git
a/rm-datasource/src/main/java/org/apache/seata/rm/datasource/undo/UndoLogParserFactory.java
b/rm-datasource/src/main/java/org/apache/seata/rm/datasource/undo/UndoLogParserFactory.java
index 020f74b5ba..807ea15642 100644
---
a/rm-datasource/src/main/java/org/apache/seata/rm/datasource/undo/UndoLogParserFactory.java
+++
b/rm-datasource/src/main/java/org/apache/seata/rm/datasource/undo/UndoLogParserFactory.java
@@ -19,16 +19,27 @@ package org.apache.seata.rm.datasource.undo;
import org.apache.seata.common.loader.EnhancedServiceLoader;
import org.apache.seata.common.util.CollectionUtils;
import org.apache.seata.common.util.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/**
* The type Undo log parser factory.
- *
*/
public class UndoLogParserFactory {
+ private static final Logger LOGGER =
LoggerFactory.getLogger(UndoLogParserFactory.class);
+ private static final Map<String, String> SERIALIZER_ALIAS_MAP = new
HashMap<>();
+
+ static {
+ SERIALIZER_ALIAS_MAP.put("fury", "fory");
+ }
+
private UndoLogParserFactory() {}
/**
@@ -58,9 +69,27 @@ public class UndoLogParserFactory {
public static UndoLogParser getInstance(String name) {
if (StringUtils.equalsIgnoreCase("fst", name)) {
throw new IllegalArgumentException(
- "Since fst is no longer maintained, this serialization
extension has been removed from version 2.0 for security and stability
reasons.");
+ "Since fst is no longer maintained, this serialization
extension has been removed from version 2.0 "
+ + "for security and stability reasons.");
+ }
+ String resolvedSerializerName = resolveSerializerName(name);
+ if (!Objects.equals(name, resolvedSerializerName)) {
+ LOGGER.info(
+ "Since {} is no longer maintained, This serialization
extension has been replaced with {}.",
+ name,
+ resolvedSerializerName);
}
return CollectionUtils.computeIfAbsent(
- INSTANCES, name, key ->
EnhancedServiceLoader.load(UndoLogParser.class, name));
+ INSTANCES, name, key ->
EnhancedServiceLoader.load(UndoLogParser.class, resolvedSerializerName));
+ }
+
+ /**
+ * Resolve serializer name from alias mapping
+ *
+ * @param serializerName the original serializer name
+ * @return the resolved serializer name
+ */
+ private static String resolveSerializerName(String serializerName) {
+ return SERIALIZER_ALIAS_MAP.getOrDefault(serializerName.toLowerCase(),
serializerName);
}
}
diff --git
a/rm-datasource/src/main/java/org/apache/seata/rm/datasource/undo/parser/FuryUndoLogParser.java
b/rm-datasource/src/main/java/org/apache/seata/rm/datasource/undo/parser/FuryUndoLogParser.java
deleted file mode 100644
index b355753ed0..0000000000
---
a/rm-datasource/src/main/java/org/apache/seata/rm/datasource/undo/parser/FuryUndoLogParser.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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 org.apache.seata.rm.datasource.undo.parser;
-
-import org.apache.fury.Fury;
-import org.apache.fury.ThreadLocalFury;
-import org.apache.fury.ThreadSafeFury;
-import org.apache.fury.config.CompatibleMode;
-import org.apache.fury.config.Language;
-import org.apache.seata.common.executor.Initialize;
-import org.apache.seata.common.loader.LoadLevel;
-import org.apache.seata.rm.datasource.undo.BranchUndoLog;
-import org.apache.seata.rm.datasource.undo.UndoLogParser;
-
-@LoadLevel(name = FuryUndoLogParser.NAME)
-public class FuryUndoLogParser implements UndoLogParser, Initialize {
- public static final String NAME = "fury";
-
- private static final ThreadSafeFury FURY = new ThreadLocalFury(classLoader
-> Fury.builder()
- .withLanguage(Language.JAVA)
- // In JAVA mode, classes cannot be registered by tag, and the
different registration order between the
- // server and the client will cause deserialization failure
- // In XLANG cross-language mode has problems with Java class
serialization, such as enum classes
- // [https://github.com/apache/fury/issues/1644].
- .requireClassRegistration(false)
- // enable reference tracking for shared/circular reference.
- .withRefTracking(true)
- .withClassLoader(classLoader)
- .withCompatibleMode(CompatibleMode.COMPATIBLE)
- .build());
-
- @Override
- public void init() {}
-
- @Override
- public String getName() {
- return NAME;
- }
-
- @Override
- public byte[] getDefaultContent() {
- return encode(new BranchUndoLog());
- }
-
- @Override
- public byte[] encode(BranchUndoLog branchUndoLog) {
- return FURY.serializeJavaObject(branchUndoLog);
- }
-
- @Override
- public BranchUndoLog decode(byte[] bytes) {
- return FURY.deserializeJavaObject(bytes, BranchUndoLog.class);
- }
-}
diff --git
a/rm-datasource/src/main/resources/META-INF/services/org.apache.seata.rm.datasource.undo.UndoLogParser
b/rm-datasource/src/main/resources/META-INF/services/org.apache.seata.rm.datasource.undo.UndoLogParser
index d9a37d043e..07c3f543c9 100644
---
a/rm-datasource/src/main/resources/META-INF/services/org.apache.seata.rm.datasource.undo.UndoLogParser
+++
b/rm-datasource/src/main/resources/META-INF/services/org.apache.seata.rm.datasource.undo.UndoLogParser
@@ -19,5 +19,4 @@
org.apache.seata.rm.datasource.undo.parser.JacksonUndoLogParser
org.apache.seata.rm.datasource.undo.parser.ProtostuffUndoLogParser
org.apache.seata.rm.datasource.undo.parser.KryoUndoLogParser
org.apache.seata.rm.datasource.undo.parser.Fastjson2UndoLogParser
-org.apache.seata.rm.datasource.undo.parser.FuryUndoLogParser
org.apache.seata.rm.datasource.undo.parser.ForyUndoLogParser
\ No newline at end of file
diff --git
a/rm-datasource/src/test/java/org/apache/seata/rm/datasource/undo/parser/FuryUndoLogParserTest.java
b/rm-datasource/src/test/java/org/apache/seata/rm/datasource/undo/parser/FuryUndoLogParserTest.java
deleted file mode 100644
index 8fbc38c456..0000000000
---
a/rm-datasource/src/test/java/org/apache/seata/rm/datasource/undo/parser/FuryUndoLogParserTest.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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 org.apache.seata.rm.datasource.undo.parser;
-
-import org.apache.seata.common.loader.EnhancedServiceLoader;
-import org.apache.seata.rm.datasource.undo.BaseUndoLogParserTest;
-import org.apache.seata.rm.datasource.undo.UndoLogParser;
-
-public class FuryUndoLogParserTest extends BaseUndoLogParserTest {
-
- FuryUndoLogParser parser =
- (FuryUndoLogParser)
EnhancedServiceLoader.load(UndoLogParser.class, FuryUndoLogParser.NAME);
-
- @Override
- public UndoLogParser getParser() {
- return parser;
- }
-
- @Override
- public void testTimestampEncodeAndDecode() {}
-}
diff --git a/serializer/pom.xml b/serializer/pom.xml
index e0aa5e5b9d..6116a410c9 100644
--- a/serializer/pom.xml
+++ b/serializer/pom.xml
@@ -38,7 +38,6 @@
<module>seata-serializer-kryo</module>
<module>seata-serializer-hessian</module>
<module>seata-serializer-fastjson2</module>
- <module>seata-serializer-fury</module>
<module>seata-serializer-fory</module>
</modules>
diff --git a/serializer/seata-serializer-all/pom.xml
b/serializer/seata-serializer-all/pom.xml
index 7d9cd6e8aa..f2ede2576f 100644
--- a/serializer/seata-serializer-all/pom.xml
+++ b/serializer/seata-serializer-all/pom.xml
@@ -55,11 +55,6 @@
<artifactId>seata-serializer-fastjson2</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>seata-serializer-fury</artifactId>
- <version>${project.version}</version>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>seata-serializer-fory</artifactId>
diff --git a/serializer/seata-serializer-fury/pom.xml
b/serializer/seata-serializer-fury/pom.xml
deleted file mode 100644
index e5310f3f8e..0000000000
--- a/serializer/seata-serializer-fury/pom.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <parent>
- <groupId>org.apache.seata</groupId>
- <artifactId>seata-serializer</artifactId>
- <version>${revision}</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>seata-serializer-fury</artifactId>
- <packaging>jar</packaging>
- <name>seata-serializer-fury ${project.version}</name>
- <description>serializer-fury for Seata built with Maven</description>
-
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>seata-core</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>seata-serializer-fory</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- <optional>true</optional>
- </dependency>
-
- <dependency>
- <groupId>org.apache.fury</groupId>
- <artifactId>fury-core</artifactId>
- <optional>true</optional>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
diff --git
a/serializer/seata-serializer-fury/src/main/java/org/apache/seata/serializer/fury/DynamicSerializerFactory.java
b/serializer/seata-serializer-fury/src/main/java/org/apache/seata/serializer/fury/DynamicSerializerFactory.java
deleted file mode 100644
index 8de2a20cf1..0000000000
---
a/serializer/seata-serializer-fury/src/main/java/org/apache/seata/serializer/fury/DynamicSerializerFactory.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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 org.apache.seata.serializer.fury;
-
-import org.apache.seata.core.serializer.Serializer;
-
-public class DynamicSerializerFactory {
- private static final DynamicSerializerFactory FACTORY = new
DynamicSerializerFactory();
-
- private final Serializer furyDelegate;
-
- private DynamicSerializerFactory() {
- this.furyDelegate = createFuryDelegate();
- }
-
- public static DynamicSerializerFactory getInstance() {
- return FACTORY;
- }
-
- public Serializer get() {
- return furyDelegate;
- }
-
- private Serializer createFuryDelegate() {
- // First, try to load seata-serializer-fory.
- try {
- Class.forName("org.apache.seata.serializer.fory.ForySerializer");
- return new ForySerializerDelegate();
- } catch (ClassNotFoundException e) {
- }
- // Second, try to load Apache Fory.
- try {
- Class.forName("org.apache.fory.Fury");
- return new ThreadSafeForyDelegate();
- } catch (ClassNotFoundException e) {
- }
- // If Fory is unavailable, fallback to Fury.
- try {
- Class.forName("org.apache.fury.Fury");
- return new ThreadSafeFuryDelegate();
- } catch (ClassNotFoundException e) {
- throw new IllegalStateException("Neither Apache Fory nor Apache
Fury found in classpath", e);
- }
- }
-}
diff --git
a/serializer/seata-serializer-fury/src/main/java/org/apache/seata/serializer/fury/ForySerializerDelegate.java
b/serializer/seata-serializer-fury/src/main/java/org/apache/seata/serializer/fury/ForySerializerDelegate.java
deleted file mode 100644
index 130092af68..0000000000
---
a/serializer/seata-serializer-fury/src/main/java/org/apache/seata/serializer/fury/ForySerializerDelegate.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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 org.apache.seata.serializer.fury;
-
-import org.apache.seata.core.serializer.Serializer;
-import org.apache.seata.serializer.fory.ForySerializer;
-
-public class ForySerializerDelegate implements Serializer {
-
- private static final ForySerializer SERIALIZER = new ForySerializer();
-
- @Override
- public byte[] serialize(Object obj) {
- return SERIALIZER.serialize(obj);
- }
-
- @Override
- public Object deserialize(byte[] bytes) {
- return SERIALIZER.deserialize(bytes);
- }
-}
diff --git
a/serializer/seata-serializer-fury/src/main/java/org/apache/seata/serializer/fury/FurySerializer.java
b/serializer/seata-serializer-fury/src/main/java/org/apache/seata/serializer/fury/FurySerializer.java
deleted file mode 100644
index 5ace1545dd..0000000000
---
a/serializer/seata-serializer-fury/src/main/java/org/apache/seata/serializer/fury/FurySerializer.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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 org.apache.seata.serializer.fury;
-
-import org.apache.seata.common.loader.LoadLevel;
-import org.apache.seata.core.protocol.AbstractMessage;
-import org.apache.seata.core.serializer.Serializer;
-
-@LoadLevel(name = "FURY")
-public class FurySerializer implements Serializer {
- @Override
- public <T> byte[] serialize(T t) {
- if (!(t instanceof AbstractMessage)) {
- throw new IllegalArgumentException("AbstractMessage isn't
available.");
- }
- Serializer serializer = DynamicSerializerFactory.getInstance().get();
- return serializer.serialize(t);
- }
-
- @Override
- public <T> T deserialize(byte[] bytes) {
- if (bytes == null || bytes.length == 0) {
- throw new IllegalArgumentException("bytes is null");
- }
- Serializer serializer = DynamicSerializerFactory.getInstance().get();
- return (T) serializer.deserialize(bytes);
- }
-}
diff --git
a/serializer/seata-serializer-fury/src/main/java/org/apache/seata/serializer/fury/ThreadSafeForyDelegate.java
b/serializer/seata-serializer-fury/src/main/java/org/apache/seata/serializer/fury/ThreadSafeForyDelegate.java
deleted file mode 100644
index 8a8843d2d4..0000000000
---
a/serializer/seata-serializer-fury/src/main/java/org/apache/seata/serializer/fury/ThreadSafeForyDelegate.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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 org.apache.seata.serializer.fury;
-
-import org.apache.fory.Fory;
-import org.apache.fory.ThreadLocalFory;
-import org.apache.fory.ThreadSafeFory;
-import org.apache.fory.config.CompatibleMode;
-import org.apache.fory.config.Language;
-import org.apache.seata.core.serializer.Serializer;
-import org.apache.seata.core.serializer.SerializerSecurityRegistry;
-
-public class ThreadSafeForyDelegate implements Serializer {
-
- private static final ThreadSafeFory FORY = new ThreadLocalFory(classLoader
-> {
- Fory f = Fory.builder()
- .withLanguage(Language.JAVA)
- // In JAVA mode, classes cannot be registered by tag, and the
different registration order between the
- // server and the client will cause deserialization failure
- // In XLANG cross-language mode has problems with Java class
serialization, such as enum classes
- // [https://github.com/apache/fory/issues/1644].
- .requireClassRegistration(false)
- // enable reference tracking for shared/circular reference.
- .withRefTracking(true)
- .withClassLoader(classLoader)
- .withCompatibleMode(CompatibleMode.COMPATIBLE)
- .build();
-
- // register allow class
- f.getClassResolver()
- .setClassChecker((classResolver, className) ->
-
SerializerSecurityRegistry.getAllowClassPattern().contains(className));
- return f;
- });
-
- @Override
- public byte[] serialize(Object obj) {
- return FORY.serialize(obj);
- }
-
- @Override
- public Object deserialize(byte[] bytes) {
- return FORY.deserialize(bytes);
- }
-}
diff --git
a/serializer/seata-serializer-fury/src/main/java/org/apache/seata/serializer/fury/ThreadSafeFuryDelegate.java
b/serializer/seata-serializer-fury/src/main/java/org/apache/seata/serializer/fury/ThreadSafeFuryDelegate.java
deleted file mode 100644
index 872558b5be..0000000000
---
a/serializer/seata-serializer-fury/src/main/java/org/apache/seata/serializer/fury/ThreadSafeFuryDelegate.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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 org.apache.seata.serializer.fury;
-
-import org.apache.fury.Fury;
-import org.apache.fury.ThreadLocalFury;
-import org.apache.fury.ThreadSafeFury;
-import org.apache.fury.config.CompatibleMode;
-import org.apache.fury.config.Language;
-import org.apache.fury.resolver.AllowListChecker;
-import org.apache.seata.core.serializer.Serializer;
-import org.apache.seata.core.serializer.SerializerSecurityRegistry;
-
-public class ThreadSafeFuryDelegate implements Serializer {
-
- private static final ThreadSafeFury FURY = new ThreadLocalFury(classLoader
-> {
- Fury f = Fury.builder()
- .withLanguage(Language.JAVA)
- // In JAVA mode, classes cannot be registered by tag, and the
different registration order between the
- // server and the client will cause deserialization failure
- // In XLANG cross-language mode has problems with Java class
serialization, such as enum classes
- // [https://github.com/apache/fury/issues/1644].
- .requireClassRegistration(false)
- // enable reference tracking for shared/circular reference.
- .withRefTracking(true)
- .withClassLoader(classLoader)
- .withCompatibleMode(CompatibleMode.COMPATIBLE)
- .build();
-
- // register allow class
- AllowListChecker checker = new
AllowListChecker(AllowListChecker.CheckLevel.STRICT);
- f.getClassResolver().setClassChecker(checker);
-
checker.allowClasses(SerializerSecurityRegistry.getAllowClassPattern());
- return f;
- });
-
- @Override
- public byte[] serialize(Object obj) {
- return FURY.serialize(obj);
- }
-
- @Override
- public Object deserialize(byte[] bytes) {
- return FURY.deserialize(bytes);
- }
-}
diff --git
a/serializer/seata-serializer-fury/src/main/resources/META-INF/services/org.apache.seata.core.serializer.Serializer
b/serializer/seata-serializer-fury/src/main/resources/META-INF/services/org.apache.seata.core.serializer.Serializer
deleted file mode 100644
index 0e125a3067..0000000000
---
a/serializer/seata-serializer-fury/src/main/resources/META-INF/services/org.apache.seata.core.serializer.Serializer
+++ /dev/null
@@ -1,17 +0,0 @@
-#
-# 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.
-#
-org.apache.seata.serializer.fury.FurySerializer
\ No newline at end of file
diff --git
a/serializer/seata-serializer-fury/src/test/java/org/apache/seata/serializer/fury/FurySerializerTest.java
b/serializer/seata-serializer-fury/src/test/java/org/apache/seata/serializer/fury/FurySerializerTest.java
deleted file mode 100644
index 6ff14c7c13..0000000000
---
a/serializer/seata-serializer-fury/src/test/java/org/apache/seata/serializer/fury/FurySerializerTest.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * 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 org.apache.seata.serializer.fury;
-
-import org.apache.fory.Fory;
-import org.apache.fury.Fury;
-import org.apache.fury.config.CompatibleMode;
-import org.apache.seata.core.exception.TransactionExceptionCode;
-import org.apache.seata.core.model.BranchStatus;
-import org.apache.seata.core.model.BranchType;
-import org.apache.seata.core.protocol.ResultCode;
-import org.apache.seata.core.protocol.transaction.BranchCommitRequest;
-import org.apache.seata.core.protocol.transaction.BranchCommitResponse;
-import org.apache.seata.core.serializer.Serializer;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Test;
-import org.seata.test.TestUnSafeSerializer;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class FurySerializerTest {
- private static FurySerializer furySerializer;
-
- @BeforeAll
- public static void before() {
- furySerializer = new FurySerializer();
- }
-
- @Test
- public void testBranchCommitRequest() {
-
- BranchCommitRequest branchCommitRequest = new BranchCommitRequest();
- branchCommitRequest.setBranchType(BranchType.AT);
- branchCommitRequest.setXid("xid");
- branchCommitRequest.setResourceId("resourceId");
- branchCommitRequest.setBranchId(20190809);
- branchCommitRequest.setApplicationData("app");
-
- byte[] bytes = furySerializer.serialize(branchCommitRequest);
- BranchCommitRequest t = furySerializer.deserialize(bytes);
-
-
assertThat(t.getTypeCode()).isEqualTo(branchCommitRequest.getTypeCode());
-
assertThat(t.getBranchType()).isEqualTo(branchCommitRequest.getBranchType());
- assertThat(t.getXid()).isEqualTo(branchCommitRequest.getXid());
-
assertThat(t.getResourceId()).isEqualTo(branchCommitRequest.getResourceId());
-
assertThat(t.getBranchId()).isEqualTo(branchCommitRequest.getBranchId());
-
assertThat(t.getApplicationData()).isEqualTo(branchCommitRequest.getApplicationData());
- }
-
- @Test
- public void testBranchCommitResponse() {
-
- BranchCommitResponse branchCommitResponse = new BranchCommitResponse();
-
branchCommitResponse.setTransactionExceptionCode(TransactionExceptionCode.BranchTransactionNotExist);
- branchCommitResponse.setBranchId(20190809);
- branchCommitResponse.setBranchStatus(BranchStatus.PhaseOne_Done);
- branchCommitResponse.setMsg("20190809");
- branchCommitResponse.setXid("20190809");
- branchCommitResponse.setResultCode(ResultCode.Failed);
-
- byte[] bytes = furySerializer.serialize(branchCommitResponse);
- BranchCommitResponse t = furySerializer.deserialize(bytes);
-
-
assertThat(t.getTransactionExceptionCode()).isEqualTo(branchCommitResponse.getTransactionExceptionCode());
-
assertThat(t.getBranchId()).isEqualTo(branchCommitResponse.getBranchId());
-
assertThat(t.getBranchStatus()).isEqualTo(branchCommitResponse.getBranchStatus());
- assertThat(t.getMsg()).isEqualTo(branchCommitResponse.getMsg());
-
assertThat(t.getResultCode()).isEqualTo(branchCommitResponse.getResultCode());
- }
-
- @Test
- public void testUnSafeDeserializer() {
- // Test deserialization of an object that is not in allow list
- TestUnSafeSerializer testUnSafeSerializer = new TestUnSafeSerializer();
- byte[] bytes = new
TestSerializerFactory().get().serialize(testUnSafeSerializer);
- String className = null;
- try {
- furySerializer.deserialize(bytes);
- } catch (Exception e) {
- className = e.getClass().getSimpleName();
- }
- Assertions.assertEquals("DeserializationException", className);
- }
-
- @Test
- public void testUnSafeSerializer() {
- // Test serialization of an object that is not in allow list
- TestUnSafeSerializer testUnSafeSerializer = new TestUnSafeSerializer();
- String className = null;
- try {
- furySerializer.serialize(testUnSafeSerializer);
- } catch (Exception e) {
- className = e.getClass().getSimpleName();
- }
- Assertions.assertEquals("InsecureException", className);
- }
-
- private static class TestSerializerFactory {
-
- private final Serializer furyDelegate;
-
- public TestSerializerFactory() {
- this.furyDelegate = createFuryDelegate();
- }
-
- public Serializer get() {
- return furyDelegate;
- }
-
- private Serializer createFuryDelegate() {
- // First, try to load Apache Fory.
- try {
- Class.forName("org.apache.fory.Fury");
- return new ForyDelegate();
- } catch (ClassNotFoundException e) {
- }
- // If Fory is unavailable, fallback to Fury.
- try {
- Class.forName("org.apache.fury.Fury");
- return new FuryDelegate();
- } catch (ClassNotFoundException e) {
- throw new IllegalStateException("Neither Apache Fory nor
Apache Fury found in classpath", e);
- }
- }
- }
-
- private static class ForyDelegate implements Serializer {
-
- @Override
- public byte[] serialize(Object obj) {
- Fory fory = Fory.builder()
- .requireClassRegistration(false)
- .withRefTracking(true)
-
.withCompatibleMode(org.apache.fory.config.CompatibleMode.COMPATIBLE)
- .build();
- return fory.serialize(obj);
- }
-
- @Override
- public Object deserialize(byte[] bytes) {
- throw new UnsupportedOperationException();
- }
- }
-
- private static class FuryDelegate implements Serializer {
-
- @Override
- public byte[] serialize(Object obj) {
- Fury fury = Fury.builder()
- .requireClassRegistration(false)
- .withRefTracking(true)
- .withCompatibleMode(CompatibleMode.COMPATIBLE)
- .build();
- return fury.serialize(obj);
- }
-
- @Override
- public Object deserialize(byte[] bytes) {
- throw new UnsupportedOperationException();
- }
- }
-}
diff --git
a/serializer/seata-serializer-fury/src/test/java/org/seata/test/TestUnSafeSerializer.java
b/serializer/seata-serializer-fury/src/test/java/org/seata/test/TestUnSafeSerializer.java
deleted file mode 100644
index 9127eedad0..0000000000
---
a/serializer/seata-serializer-fury/src/test/java/org/seata/test/TestUnSafeSerializer.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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 org.seata.test;
-
-import org.apache.seata.core.protocol.AbstractMessage;
-
-public class TestUnSafeSerializer extends AbstractMessage {
- @Override
- public short getTypeCode() {
- return 0;
- }
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]