This is an automated email from the ASF dual-hosted git repository.
xingfudeshi 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 55c51644bd optimize:optimize lz4 compressor (#7829)
55c51644bd is described below
commit 55c51644bd54e543057e17d66f6f3c1bc00127d6
Author: Jiangke Wu <[email protected]>
AuthorDate: Thu Dec 4 10:46:36 2025 +0800
optimize:optimize lz4 compressor (#7829)
---
all/pom.xml | 2 +-
changes/en-us/2.x.md | 1 +
changes/zh-cn/2.x.md | 1 +
compressor/seata-compressor-lz4/pom.xml | 2 +-
.../java/org/apache/seata/compressor/lz4/Lz4Util.java | 17 +++++------------
dependencies/pom.xml | 4 ++--
distribution/LICENSE | 2 +-
distribution/LICENSE-server | 4 ++--
8 files changed, 14 insertions(+), 19 deletions(-)
diff --git a/all/pom.xml b/all/pom.xml
index fefcbc8b4a..82e67e12a2 100644
--- a/all/pom.xml
+++ b/all/pom.xml
@@ -633,7 +633,7 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.lz4</groupId>
+ <groupId>at.yawk.lz4</groupId>
<artifactId>lz4-java</artifactId>
<scope>provided</scope>
</dependency>
diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md
index e29d182ac0..7330594eb8 100644
--- a/changes/en-us/2.x.md
+++ b/changes/en-us/2.x.md
@@ -79,6 +79,7 @@ Add changes here for all PR submitted to the 2.x branch.
- [[#7740](https://github.com/apache/incubator-seata/pull/7740)] enhance
HttpClient to support h2c
- [[#7781](https://github.com/apache/incubator-seata/pull/7781)] highlight
pmd-check log
- [[#7813](https://github.com/apache/incubator-seata/pull/7813)] add decode
buffer limit
+- [[#7829](https://github.com/apache/incubator-seata/pull/7829)] optimize lz4
compressor
diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md
index 544fb31075..8b7761e8f6 100644
--- a/changes/zh-cn/2.x.md
+++ b/changes/zh-cn/2.x.md
@@ -78,6 +78,7 @@
- [[#7740](https://github.com/apache/incubator-seata/pull/7740)]
优化http工具类使之支持h2c协议
- [[#7781](https://github.com/apache/incubator-seata/pull/7781)] 高亮 pmd 检查日志信息
- [[#7813](https://github.com/apache/incubator-seata/pull/7813)] 增加解码buffer限制
+- [[#7829](https://github.com/apache/incubator-seata/pull/7829)] 优化lz4
compressor
### security:
diff --git a/compressor/seata-compressor-lz4/pom.xml
b/compressor/seata-compressor-lz4/pom.xml
index b31e18a05f..5635ae7ca9 100644
--- a/compressor/seata-compressor-lz4/pom.xml
+++ b/compressor/seata-compressor-lz4/pom.xml
@@ -38,7 +38,7 @@
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.lz4</groupId>
+ <groupId>at.yawk.lz4</groupId>
<artifactId>lz4-java</artifactId>
</dependency>
</dependencies>
diff --git
a/compressor/seata-compressor-lz4/src/main/java/org/apache/seata/compressor/lz4/Lz4Util.java
b/compressor/seata-compressor-lz4/src/main/java/org/apache/seata/compressor/lz4/Lz4Util.java
index 82a009c519..8984ca7e05 100644
---
a/compressor/seata-compressor-lz4/src/main/java/org/apache/seata/compressor/lz4/Lz4Util.java
+++
b/compressor/seata-compressor-lz4/src/main/java/org/apache/seata/compressor/lz4/Lz4Util.java
@@ -16,11 +16,8 @@
*/
package org.apache.seata.compressor.lz4;
-import net.jpountz.lz4.LZ4BlockInputStream;
-import net.jpountz.lz4.LZ4BlockOutputStream;
-import net.jpountz.lz4.LZ4Compressor;
-import net.jpountz.lz4.LZ4Factory;
-import net.jpountz.lz4.LZ4FastDecompressor;
+import net.jpountz.lz4.LZ4FrameInputStream;
+import net.jpountz.lz4.LZ4FrameOutputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -40,11 +37,9 @@ public class Lz4Util {
if (bytes == null) {
throw new NullPointerException("bytes is null");
}
- LZ4Compressor compressor =
LZ4Factory.fastestInstance().fastCompressor();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- try (LZ4BlockOutputStream lz4BlockOutputStream =
- new LZ4BlockOutputStream(outputStream, ARRAY_SIZE,
compressor)) {
- lz4BlockOutputStream.write(bytes);
+ try (LZ4FrameOutputStream lz4OutputStream = new
LZ4FrameOutputStream(outputStream)) {
+ lz4OutputStream.write(bytes);
} catch (IOException e) {
LOGGER.error("compress bytes error", e);
}
@@ -57,10 +52,8 @@ public class Lz4Util {
}
ByteArrayOutputStream outputStream = new
ByteArrayOutputStream(ARRAY_SIZE);
-
- LZ4FastDecompressor decompressor =
LZ4Factory.fastestInstance().fastDecompressor();
ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
- try (LZ4BlockInputStream decompressedInputStream = new
LZ4BlockInputStream(inputStream, decompressor)) {
+ try (LZ4FrameInputStream decompressedInputStream = new
LZ4FrameInputStream(inputStream)) {
int count;
byte[] buffer = new byte[ARRAY_SIZE];
while ((count = decompressedInputStream.read(buffer)) != -1) {
diff --git a/dependencies/pom.xml b/dependencies/pom.xml
index f566f52f6a..7519faf6a0 100644
--- a/dependencies/pom.xml
+++ b/dependencies/pom.xml
@@ -72,7 +72,7 @@
<bucket4j.version>8.1.0</bucket4j.version>
<commons-compress.version>1.27.1</commons-compress.version>
<ant.version>1.10.12</ant.version>
- <lz4.version>1.7.1</lz4.version>
+ <lz4.version>1.9.0</lz4.version>
<jraft.version>1.3.14</jraft.version>
<snakeyaml.version>2.0</snakeyaml.version>
<netty.version>4.1.101.Final</netty.version>
@@ -696,7 +696,7 @@
<version>${ant.version}</version>
</dependency>
<dependency>
- <groupId>org.lz4</groupId>
+ <groupId>at.yawk.lz4</groupId>
<artifactId>lz4-java</artifactId>
<version>${lz4.version}</version>
</dependency>
diff --git a/distribution/LICENSE b/distribution/LICENSE
index 85ccd9f346..c2bb70387f 100644
--- a/distribution/LICENSE
+++ b/distribution/LICENSE
@@ -372,7 +372,7 @@ Apache-2.0 licenses
org.jetbrains.kotlinx:kotlinx-coroutines-core 1.7.3 Apache-2.0
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm 1.7.3 Apache-2.0
org.jetbrains:annotations 13.0 Apache-2.0
- org.lz4:lz4-java 1.7.1 Apache-2.0
+ at.yawk.lz4:lz4-java 1.9.0 Apache-2.0
org.objenesis:objenesis 3.3 Apache-2.0
org.objenesis:objenesis 3.2 Apache-2.0
org.springframework.boot:spring-boot 2.7.18 Apache-2.0
diff --git a/distribution/LICENSE-server b/distribution/LICENSE-server
index 1fbffde572..a1f49df4ec 100644
--- a/distribution/LICENSE-server
+++ b/distribution/LICENSE-server
@@ -289,7 +289,7 @@ Apache-2.0 licenses
org.apache.kafka:kafka-clients 3.6.1 Apache-2.0
de.javakaffee:kryo-serializers 0.45 Apache-2.0
com.github.danielwegener:logback-kafka-appender 0.2.0-RC2 Apache-2.0
- org.lz4:lz4-java 1.7.1 Apache-2.0
+ at.yawk.lz4:lz4-java 1.9.0 Apache-2.0
com.alibaba.nacos:nacos-api 1.4.6 Apache-2.0
com.alibaba.nacos:nacos-client 1.4.6 Apache-2.0
com.alibaba.nacos:nacos-common 1.4.6 Apache-2.0
@@ -434,4 +434,4 @@ Public Domain licenses
Indiana University Extreme! Lab Software License
========================================================================
- io.github.x-stream:mxparser 1.2.2 Indiana University Extreme! Lab Software
License see:licenses/mxparser-IUELSL
\ No newline at end of file
+ io.github.x-stream:mxparser 1.2.2 Indiana University Extreme! Lab Software
License see:licenses/mxparser-IUELSL
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]