Skip to content

Commit f8359f0

Browse files
authored
[release]: release for 1.4.1
2 parents f270a2d + 9569bed commit f8359f0

File tree

69 files changed

+786
-274
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+786
-274
lines changed

all/pom.xml

+9-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
<groupId>io.seata</groupId>
2323
<artifactId>seata-all</artifactId>
24-
<version>1.4.0</version>
24+
<version>1.4.1</version>
2525

2626
<name>Seata All-in-one ${project.version}</name>
2727
<url>http://seata.io</url>
@@ -289,6 +289,11 @@
289289
<artifactId>seata-compressor-lz4</artifactId>
290290
<version>${project.version}</version>
291291
</dependency>
292+
<dependency>
293+
<groupId>io.seata</groupId>
294+
<artifactId>seata-compressor-deflater</artifactId>
295+
<version>${project.version}</version>
296+
</dependency>
292297

293298
<!-- saga -->
294299
<dependency>
@@ -681,11 +686,13 @@
681686
<include>io.seata:seata-saga-rm</include>
682687
<include>io.seata:seata-saga-tm</include>
683688
<include>io.seata:seata-saga-engine-store</include>
689+
<!--compressor-->
684690
<include>io.seata:seata-compressor-gzip</include>
685691
<include>io.seata:seata-compressor-7z</include>
686692
<include>io.seata:seata-compressor-bzip2</include>
687693
<include>io.seata:seata-compressor-zip</include>
688694
<include>io.seata:seata-compressor-lz4</include>
695+
<include>io.seata:seata-compressor-deflater</include>
689696
</includes>
690697
</artifactSet>
691698
<transformers>
@@ -771,6 +778,7 @@
771778
<serverId>oss_seata</serverId>
772779
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
773780
<autoReleaseAfterClose>false</autoReleaseAfterClose>
781+
<skipStagingRepositoryClose>true</skipStagingRepositoryClose>
774782
</configuration>
775783
</plugin>
776784
<plugin>

bom/pom.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
<groupId>io.seata</groupId>
2222
<artifactId>seata-bom</artifactId>
23-
<version>1.4.0</version>
23+
<version>1.4.1</version>
2424

2525
<modelVersion>4.0.0</modelVersion>
2626
<packaging>pom</packaging>
@@ -567,6 +567,7 @@
567567
<serverId>oss_seata</serverId>
568568
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
569569
<autoReleaseAfterClose>false</autoReleaseAfterClose>
570+
<skipStagingRepositoryClose>true</skipStagingRepositoryClose>
570571
</configuration>
571572
</plugin>
572573
<plugin>

common/src/main/java/io/seata/common/exception/FrameworkErrorCode.java

+5
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,11 @@ public enum FrameworkErrorCode {
206206
*/
207207
StateMachineExecutionTimeout("0421", "State machine execution timeout", "State machine execution timeout"),
208208

209+
/**
210+
* State machine execution no choice matched
211+
*/
212+
StateMachineNoChoiceMatched("0422", "State machine no choice matched", "State machine no choice matched"),
213+
209214
/**
210215
* Undefined error
211216
*/

common/src/main/java/io/seata/common/thread/NamedThreadFactory.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*/
3232
public class NamedThreadFactory implements ThreadFactory {
3333
private final static Map<String, AtomicInteger> PREFIX_COUNTER = new ConcurrentHashMap<>();
34-
34+
private final ThreadGroup group;
3535
private final AtomicInteger counter = new AtomicInteger(0);
3636
private final String prefix;
3737
private final int totalSize;
@@ -47,6 +47,8 @@ public class NamedThreadFactory implements ThreadFactory {
4747
public NamedThreadFactory(String prefix, int totalSize, boolean makeDaemons) {
4848
int prefixCounter = CollectionUtils.computeIfAbsent(PREFIX_COUNTER, prefix, key -> new AtomicInteger(0))
4949
.incrementAndGet();
50+
SecurityManager securityManager = System.getSecurityManager();
51+
group = (securityManager != null) ? securityManager.getThreadGroup() : Thread.currentThread().getThreadGroup();
5052
this.prefix = prefix + "_" + prefixCounter;
5153
this.makeDaemons = makeDaemons;
5254
this.totalSize = totalSize;
@@ -78,7 +80,7 @@ public Thread newThread(Runnable r) {
7880
if (totalSize > 1) {
7981
name += "_" + totalSize;
8082
}
81-
Thread thread = new FastThreadLocalThread(r, name);
83+
Thread thread = new FastThreadLocalThread(group, r, name);
8284

8385
thread.setDaemon(makeDaemons);
8486
if (thread.getPriority() != Thread.NORM_PRIORITY) {

common/src/test/java/io/seata/common/thread/NamedThreadFactoryTest.java

+8
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,12 @@ public void testThreadNameHasCounterWithPrefixCounter() {
6565
.isEqualTo(thread.getName());
6666
}
6767
}
68+
69+
@Test
70+
public void testNamedThreadFactoryWithSecurityManager() {
71+
NamedThreadFactory factory = new NamedThreadFactory("testThreadGroup", true);
72+
Thread thread = factory.newThread(() -> {});
73+
assertThat(thread.getThreadGroup()).isNotNull();
74+
}
75+
6876
}

compressor/pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<module>seata-compressor-7z</module>
3535
<module>seata-compressor-bzip2</module>
3636
<module>seata-compressor-lz4</module>
37+
<module>seata-compressor-deflater</module>
3738
</modules>
3839

3940

compressor/seata-compressor-all/pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@
4747
<artifactId>seata-compressor-zip</artifactId>
4848
<version>${project.version}</version>
4949
</dependency>
50+
<dependency>
51+
<groupId>${project.groupId}</groupId>
52+
<artifactId>seata-compressor-deflater</artifactId>
53+
<version>${project.version}</version>
54+
</dependency>
5055
</dependencies>
5156

5257
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright 1999-2019 Seata.io Group.
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
<project xmlns="http://maven.apache.org/POM/4.0.0"
18+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
20+
<parent>
21+
<groupId>io.seata</groupId>
22+
<artifactId>seata-compressor</artifactId>
23+
<version>${revision}</version>
24+
</parent>
25+
<modelVersion>4.0.0</modelVersion>
26+
<artifactId>seata-compressor-deflater</artifactId>
27+
<packaging>jar</packaging>
28+
<name>seata-compressor-deflater ${project.version}</name>
29+
30+
<dependencies>
31+
<dependency>
32+
<groupId>${project.groupId}</groupId>
33+
<artifactId>seata-core</artifactId>
34+
<version>${project.version}</version>
35+
</dependency>
36+
</dependencies>
37+
38+
39+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 1999-2019 Seata.io Group.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.seata.compressor.deflater;
17+
18+
import io.seata.common.loader.LoadLevel;
19+
import io.seata.core.compressor.Compressor;
20+
21+
/**
22+
* @author dongzl
23+
*/
24+
@LoadLevel(name = "DEFLATER")
25+
public class DeflaterCompressor implements Compressor {
26+
27+
@Override
28+
public byte[] compress(byte[] bytes) {
29+
return DeflaterUtil.compress(bytes);
30+
}
31+
32+
@Override
33+
public byte[] decompress(byte[] bytes) {
34+
return DeflaterUtil.decompress(bytes);
35+
}
36+
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* Copyright 1999-2019 Seata.io Group.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.seata.compressor.deflater;
17+
18+
import java.io.ByteArrayOutputStream;
19+
import java.io.IOException;
20+
import java.util.zip.Deflater;
21+
import java.util.zip.Inflater;
22+
23+
/**
24+
* @author dongzl
25+
*/
26+
public class DeflaterUtil {
27+
28+
private DeflaterUtil() {
29+
30+
}
31+
32+
private static final int BUFFER_SIZE = 8192;
33+
34+
public static byte[] compress(byte[] bytes) {
35+
if (bytes == null) {
36+
throw new NullPointerException("bytes is null");
37+
}
38+
int lenght = 0;
39+
Deflater deflater = new Deflater();
40+
deflater.setInput(bytes);
41+
deflater.finish();
42+
byte[] outputBytes = new byte[BUFFER_SIZE];
43+
try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
44+
while (!deflater.finished()) {
45+
lenght = deflater.deflate(outputBytes);
46+
bos.write(outputBytes, 0, lenght);
47+
}
48+
deflater.end();
49+
return bos.toByteArray();
50+
} catch (IOException e) {
51+
throw new RuntimeException("Deflater compress error", e);
52+
}
53+
}
54+
55+
public static byte[] decompress(byte[] bytes) {
56+
if (bytes == null) {
57+
throw new NullPointerException("bytes is null");
58+
}
59+
int length = 0;
60+
Inflater inflater = new Inflater();
61+
inflater.setInput(bytes);
62+
byte[] outputBytes = new byte[BUFFER_SIZE];
63+
try (ByteArrayOutputStream bos = new ByteArrayOutputStream();) {
64+
while (!inflater.finished()) {
65+
length = inflater.inflate(outputBytes);
66+
if (length == 0) {
67+
break;
68+
}
69+
bos.write(outputBytes, 0, length);
70+
}
71+
inflater.end();
72+
return bos.toByteArray();
73+
} catch (Exception e) {
74+
throw new RuntimeException("Deflater decompress error", e);
75+
}
76+
}
77+
78+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
io.seata.compressor.deflater.DeflaterCompressor
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright 1999-2019 Seata.io Group.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.seata.compressor.deflater;
17+
18+
import org.junit.jupiter.api.Assertions;
19+
import org.junit.jupiter.api.Test;
20+
21+
/**
22+
* @author dongzl
23+
*/
24+
public class DeflaterCompressorTest {
25+
26+
@Test
27+
public void testCompressAndDecompress() {
28+
DeflaterCompressor compressor = new DeflaterCompressor();
29+
byte[] bytes = "seata".getBytes();
30+
bytes = compressor.compress(bytes);
31+
bytes = compressor.decompress(bytes);
32+
Assertions.assertEquals(new String(bytes), "seata");
33+
}
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright 1999-2019 Seata.io Group.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.seata.compressor.deflater;
17+
18+
import org.junit.jupiter.api.Assertions;
19+
import org.junit.jupiter.api.Test;
20+
21+
/**
22+
* @author dongzl
23+
*/
24+
public class DeflaterUtilTest {
25+
26+
@Test
27+
public void test_compress() {
28+
Assertions.assertThrows(NullPointerException.class, () -> {
29+
DeflaterUtil.compress(null);
30+
});
31+
}
32+
33+
@Test
34+
public void test_decompress() {
35+
Assertions.assertThrows(NullPointerException.class, () -> {
36+
DeflaterUtil.decompress(null);
37+
});
38+
}
39+
40+
@Test
41+
public void test_compressEqualDecompress() {
42+
byte[] compress = DeflaterUtil.compress("seata".getBytes());
43+
byte[] decompress = DeflaterUtil.decompress(compress);
44+
Assertions.assertEquals("seata", new String(decompress));
45+
}
46+
47+
}

core/src/main/java/io/seata/core/compressor/CompressorType.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@ public enum CompressorType {
4848
/**
4949
* The lz4.
5050
*/
51-
LZ4((byte) 5);
51+
LZ4((byte) 5),
52+
53+
/**
54+
* The deflater.
55+
*/
56+
DEFLATER((byte) 6);
5257

5358
private final byte code;
5459

0 commit comments

Comments
 (0)