chore(project): 添加项目配置文件和忽略规则

- 添加 Babel 配置文件支持 ES6+ 语法转换
- 添加 ESLint 忽略规则和配置文件
- 添加 Git 忽略规则文件
- 添加 Travis CI 配置文件
- 添加 1.4.2 版本变更日志文件
- 添加 Helm 图表辅助模板文件
- 添加 Helm 忽略规则文件
This commit is contained in:
2026-03-27 17:36:48 +08:00
commit c2453d6434
1703 changed files with 277582 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 1999-2019 Seata.io Group.
~
~ Licensed 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>
<artifactId>seata-serializer</artifactId>
<groupId>io.seata</groupId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>seata-serializer-hessian</artifactId>
<packaging>jar</packaging>
<name>seata-serializer-hessian ${project.version}</name>
<dependencies>
<dependency>
<groupId>com.caucho</groupId>
<artifactId>hessian</artifactId>
</dependency>
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-core</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,66 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed 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.serializer.hessian;
import com.caucho.hessian.io.Hessian2Input;
import com.caucho.hessian.io.Hessian2Output;
import com.caucho.hessian.io.SerializerFactory;
import io.seata.common.loader.LoadLevel;
import io.seata.core.serializer.Serializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
/**
* @author XinWang
*/
@LoadLevel(name = "HESSIAN")
public class HessianSerializer implements Serializer {
private static final Logger LOGGER = LoggerFactory.getLogger(HessianSerializer.class);
@Override
public <T> byte[] serialize(T t) {
byte[] stream = null;
SerializerFactory hessian = HessianSerializerFactory.getInstance();
try {
com.caucho.hessian.io.Serializer serializer = hessian.getSerializer(t.getClass());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Hessian2Output output = new Hessian2Output(baos);
serializer.writeObject(t, output);
output.close();
stream = baos.toByteArray();
} catch (IOException e) {
LOGGER.error("Hessian encode error:{}", e.getMessage(), e);
}
return stream;
}
@Override
public <T> T deserialize(byte[] bytes) {
T obj = null;
try (ByteArrayInputStream is = new ByteArrayInputStream(bytes);) {
Hessian2Input input = new Hessian2Input(is);
obj = (T) input.readObject();
input.close();
} catch (IOException e) {
LOGGER.error("Hessian decode error:{}", e.getMessage(), e);
}
return obj;
}
}

View File

@@ -0,0 +1,46 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed 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.serializer.hessian;
import com.caucho.hessian.io.Deserializer;
import com.caucho.hessian.io.HessianProtocolException;
import com.caucho.hessian.io.Serializer;
import com.caucho.hessian.io.SerializerFactory;
/*
* @Xin Wang
*/
public class HessianSerializerFactory extends SerializerFactory {
public static final SerializerFactory INSTANCE = new HessianSerializerFactory();
private HessianSerializerFactory() {
super();
}
public static SerializerFactory getInstance() {
return INSTANCE;
}
@Override
protected Serializer loadSerializer(Class<?> cl) throws HessianProtocolException {
return super.loadSerializer(cl);
}
@Override
protected Deserializer loadDeserializer(Class cl) throws HessianProtocolException {
return super.loadDeserializer(cl);
}
}

View File

@@ -0,0 +1 @@
io.seata.serializer.hessian.HessianSerializer

View File

@@ -0,0 +1,85 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed 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.serializer.hessian;
import io.seata.core.exception.TransactionExceptionCode;
import io.seata.core.model.BranchStatus;
import io.seata.core.model.BranchType;
import io.seata.core.protocol.ResultCode;
import io.seata.core.protocol.transaction.BranchCommitRequest;
import io.seata.core.protocol.transaction.BranchCommitResponse;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Xin Wang
*/
public class HessianSerializerTest {
private static HessianSerializer hessianCodec;
@BeforeAll
public static void before() {
hessianCodec = new HessianSerializer();
}
@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 = hessianCodec.serialize(branchCommitRequest);
BranchCommitRequest t = hessianCodec.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 = hessianCodec.serialize(branchCommitResponse);
BranchCommitResponse t = hessianCodec.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());
}
}