From bbf5c1ce840f6e295b4f2c9b397bfe8adba44431 Mon Sep 17 00:00:00 2001 From: "minghua.xie" Date: Sat, 30 Nov 2024 19:50:11 +0800 Subject: [PATCH] sdk version to protocol version --- .../core/protocol/ProtocolConstants.java | 9 +- .../seata/core/rpc/netty/ProtocolDecoder.java | 1 + .../seata/core/rpc/netty/ProtocolEncoder.java | 2 + .../core/rpc/netty/v0/ProtocolDecoderV0.java | 8 +- .../core/rpc/netty/v0/ProtocolEncoderV0.java | 9 +- .../core/rpc/netty/v1/ProtocolDecoderV1.java | 21 ++--- .../core/rpc/netty/v1/ProtocolEncoderV1.java | 24 ++---- .../core/rpc/netty/v2/ProtocolDecoderV2.java | 31 +++++++ .../core/rpc/netty/v2/ProtocolEncoderV2.java | 30 +++++++ .../serializer/SerializerServiceLoader.java | 8 +- .../serializer/seata/MessageCodecFactory.java | 15 +++- .../serializer/seata/SeataSerializer.java | 83 +++---------------- .../AbstractIdentifyResponseCodec.java | 2 - .../protocol/RegisterRMResponseCodec.java | 61 +------------- .../protocol/RegisterTMResponseCodec.java | 58 +------------ .../v2/AbstractIdentifyResponseCodecV2.java | 55 ++++++++++++ .../v2/RegisterRMResponseCodecV2.java | 32 +++++++ .../v2/RegisterTMResponseCodecV2.java | 32 +++++++ .../seata/serializer/SeataSerializerV1.java | 74 +++++++++++++++++ .../seata/serializer/SeataSerializerV2.java | 31 +++++++ .../BatchResultMessageSerializerTest.java | 6 +- .../MergeResultMessageSerializerTest.java | 4 +- .../MergedWarpMessageSerializerTest.java | 5 +- .../RegisterRMRequestSerializerTest.java | 4 +- .../RegisterRMResponseSerializerTest.java | 4 +- .../RegisterTMRequestSerializerTest.java | 4 +- .../RegisterTMResponseSerializerTest.java | 4 +- .../BranchCommitRequestSerializerTest.java | 4 +- .../BranchCommitResponseSerializerTest.java | 4 +- .../BranchRegisterRequestSerializerTest.java | 4 +- .../BranchRegisterResponseSerializerTest.java | 4 +- .../BranchReportRequestSerializerTest.java | 4 +- .../BranchReportResponseSerializerTest.java | 4 +- .../BranchRollbackRequestSerializerTest.java | 4 +- .../BranchRollbackResponseSerializerTest.java | 4 +- .../GlobalBeginRequestSerializerTest.java | 4 +- .../GlobalBeginResponseSerializerTest.java | 4 +- .../GlobalCommitRequestCodecTest.java | 4 +- .../GlobalCommitResponseSerializerTest.java | 4 +- .../GlobalLockQueryRequestSerializerTest.java | 4 +- ...GlobalLockQueryResponseSerializerTest.java | 4 +- .../GlobalRollbackRequestCodecTest.java | 4 +- .../GlobalRollbackResponseSerializerTest.java | 4 +- .../GlobalStatusRequestCodecTest.java | 4 +- .../GlobalStatusResponseSerializerTest.java | 4 +- .../UndoLogDeleteRequestSerializerTest.java | 4 +- 46 files changed, 404 insertions(+), 289 deletions(-) create mode 100644 core/src/main/java/org/apache/seata/core/rpc/netty/v2/ProtocolDecoderV2.java create mode 100644 core/src/main/java/org/apache/seata/core/rpc/netty/v2/ProtocolEncoderV2.java create mode 100644 serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/protocol/v2/AbstractIdentifyResponseCodecV2.java create mode 100644 serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/protocol/v2/RegisterRMResponseCodecV2.java create mode 100644 serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/protocol/v2/RegisterTMResponseCodecV2.java create mode 100644 serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/serializer/SeataSerializerV1.java create mode 100644 serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/serializer/SeataSerializerV2.java 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 4b2b7ef8700..f279c30aaad 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 @@ -38,14 +38,19 @@ public interface ProtocolConstants { byte VERSION_0 = 0; /** - * Protocol version + * Protocol version 1 */ byte VERSION_1 = 1; + /** + * Protocol version 2 + */ + byte VERSION_2 = 2; + /** * Protocol version */ - byte VERSION = VERSION_1; + byte VERSION = VERSION_2; /** * Max frame length diff --git a/core/src/main/java/org/apache/seata/core/rpc/netty/ProtocolDecoder.java b/core/src/main/java/org/apache/seata/core/rpc/netty/ProtocolDecoder.java index d28506fd841..9d2cb828574 100644 --- a/core/src/main/java/org/apache/seata/core/rpc/netty/ProtocolDecoder.java +++ b/core/src/main/java/org/apache/seata/core/rpc/netty/ProtocolDecoder.java @@ -27,4 +27,5 @@ public interface ProtocolDecoder { RpcMessage decodeFrame(ByteBuf in); + byte protocolVersion(); } diff --git a/core/src/main/java/org/apache/seata/core/rpc/netty/ProtocolEncoder.java b/core/src/main/java/org/apache/seata/core/rpc/netty/ProtocolEncoder.java index 6c91164fff3..09363cc880b 100644 --- a/core/src/main/java/org/apache/seata/core/rpc/netty/ProtocolEncoder.java +++ b/core/src/main/java/org/apache/seata/core/rpc/netty/ProtocolEncoder.java @@ -25,4 +25,6 @@ **/ public interface ProtocolEncoder { void encode(RpcMessage rpcMessage, ByteBuf out); + + byte protocolVersion(); } diff --git a/core/src/main/java/org/apache/seata/core/rpc/netty/v0/ProtocolDecoderV0.java b/core/src/main/java/org/apache/seata/core/rpc/netty/v0/ProtocolDecoderV0.java index 1cea913ac74..c9195f1793e 100644 --- a/core/src/main/java/org/apache/seata/core/rpc/netty/v0/ProtocolDecoderV0.java +++ b/core/src/main/java/org/apache/seata/core/rpc/netty/v0/ProtocolDecoderV0.java @@ -24,7 +24,6 @@ import org.apache.seata.core.protocol.ProtocolConstants; import org.apache.seata.core.protocol.RpcMessage; -import org.apache.seata.core.protocol.Version; import org.apache.seata.core.rpc.netty.ProtocolDecoder; import org.apache.seata.core.serializer.Serializer; import org.apache.seata.core.serializer.SerializerServiceLoader; @@ -131,7 +130,7 @@ public RpcMessage decodeFrame(ByteBuf in) { bs2[1] = (byte) (0x00FF & typeCode); System.arraycopy(bs, 0, bs2, 2, length); byte codecType = isSeataCodec ? SerializerType.SEATA.getCode() : SerializerType.HESSIAN.getCode(); - Serializer serializer = SerializerServiceLoader.load(SerializerType.getByCode(codecType), Version.VERSION_0_7_0); + Serializer serializer = SerializerServiceLoader.load(SerializerType.getByCode(codecType), protocolVersion()); rpcMessage.setBody(serializer.deserialize(bs2)); } catch (Exception e) { LOGGER.error("decode error", e); @@ -152,4 +151,9 @@ protected Object decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception throw new DecodeException(exx); } } + + @Override + public byte protocolVersion(){ + return ProtocolConstants.VERSION_0; + } } diff --git a/core/src/main/java/org/apache/seata/core/rpc/netty/v0/ProtocolEncoderV0.java b/core/src/main/java/org/apache/seata/core/rpc/netty/v0/ProtocolEncoderV0.java index 5bb618185f1..15a6f21c9ad 100644 --- a/core/src/main/java/org/apache/seata/core/rpc/netty/v0/ProtocolEncoderV0.java +++ b/core/src/main/java/org/apache/seata/core/rpc/netty/v0/ProtocolEncoderV0.java @@ -21,8 +21,8 @@ import io.netty.handler.codec.MessageToByteEncoder; import org.apache.seata.core.protocol.HeartbeatMessage; import org.apache.seata.core.protocol.MessageTypeAware; +import org.apache.seata.core.protocol.ProtocolConstants; import org.apache.seata.core.protocol.RpcMessage; -import org.apache.seata.core.protocol.Version; import org.apache.seata.core.rpc.netty.ProtocolEncoder; import org.apache.seata.core.serializer.Serializer; import org.apache.seata.core.serializer.SerializerServiceLoader; @@ -82,7 +82,7 @@ public void encode(RpcMessage message, ByteBuf out) { } byte[] bodyBytes = null; - Serializer serializer = SerializerServiceLoader.load(SerializerType.getByCode(codec), Version.VERSION_0_7_0); + Serializer serializer = SerializerServiceLoader.load(SerializerType.getByCode(codec), protocolVersion()); bodyBytes = serializer.serialize(msg.getBody()); if (msg.isSeataCodec()) { @@ -118,4 +118,9 @@ protected void encode(ChannelHandlerContext ctx, Object msg, ByteBuf out) throws LOGGER.error("Encode request error!", e); } } + + @Override + public byte protocolVersion(){ + return ProtocolConstants.VERSION_0; + } } diff --git a/core/src/main/java/org/apache/seata/core/rpc/netty/v1/ProtocolDecoderV1.java b/core/src/main/java/org/apache/seata/core/rpc/netty/v1/ProtocolDecoderV1.java index 62286a7c221..1eac5905b66 100644 --- a/core/src/main/java/org/apache/seata/core/rpc/netty/v1/ProtocolDecoderV1.java +++ b/core/src/main/java/org/apache/seata/core/rpc/netty/v1/ProtocolDecoderV1.java @@ -22,16 +22,12 @@ import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.LengthFieldBasedFrameDecoder; -import org.apache.seata.common.util.StringUtils; import org.apache.seata.core.compressor.Compressor; import org.apache.seata.core.compressor.CompressorFactory; import org.apache.seata.core.exception.DecodeException; import org.apache.seata.core.protocol.HeartbeatMessage; import org.apache.seata.core.protocol.ProtocolConstants; import org.apache.seata.core.protocol.RpcMessage; -import org.apache.seata.core.protocol.Version; -import org.apache.seata.core.rpc.RpcContext; -import org.apache.seata.core.rpc.netty.ChannelManager; import org.apache.seata.core.rpc.netty.ProtocolDecoder; import org.apache.seata.core.serializer.Serializer; import org.apache.seata.core.serializer.SerializerServiceLoader; @@ -90,10 +86,6 @@ int lengthFieldLength, FullLength is int(4B). so values is 4 @Override public RpcMessage decodeFrame(ByteBuf frame) { - return decodeFrame(null, frame); - } - - public RpcMessage decodeFrame(ChannelHandlerContext ctx, ByteBuf frame) { byte b0 = frame.readByte(); byte b1 = frame.readByte(); if (ProtocolConstants.MAGIC_CODE_BYTES[0] != b0 @@ -137,12 +129,7 @@ public RpcMessage decodeFrame(ChannelHandlerContext ctx, ByteBuf frame) { bs = compressor.decompress(bs); SerializerType protocolType = SerializerType.getByCode(rpcMessage.getCodec()); if (this.supportDeSerializerTypes.contains(protocolType)) { - String sdkVersion = ""; - if(ctx != null && ctx.channel() != null){ - sdkVersion = Version.getChannelVersion(ctx.channel()); - sdkVersion = StringUtils.isBlank(sdkVersion) ? "" : sdkVersion; - } - Serializer serializer = SerializerServiceLoader.load(protocolType, sdkVersion); + Serializer serializer = SerializerServiceLoader.load(protocolType, ProtocolConstants.VERSION_1); rpcMessage.setBody(serializer.deserialize(bs)); } else { throw new IllegalArgumentException("SerializerType not match"); @@ -161,7 +148,7 @@ protected Object decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception if (decoded instanceof ByteBuf) { ByteBuf frame = (ByteBuf)decoded; try { - return decodeFrame(ctx, frame); + return decodeFrame(frame); } finally { frame.release(); } @@ -173,4 +160,8 @@ protected Object decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception return decoded; } + @Override + public byte protocolVersion(){ + return ProtocolConstants.VERSION_1; + } } diff --git a/core/src/main/java/org/apache/seata/core/rpc/netty/v1/ProtocolEncoderV1.java b/core/src/main/java/org/apache/seata/core/rpc/netty/v1/ProtocolEncoderV1.java index 9081796c73d..34185022866 100644 --- a/core/src/main/java/org/apache/seata/core/rpc/netty/v1/ProtocolEncoderV1.java +++ b/core/src/main/java/org/apache/seata/core/rpc/netty/v1/ProtocolEncoderV1.java @@ -19,10 +19,6 @@ import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToByteEncoder; -import org.apache.seata.common.util.StringUtils; -import org.apache.seata.core.protocol.Version; -import org.apache.seata.core.rpc.RpcContext; -import org.apache.seata.core.rpc.netty.ChannelManager; import org.apache.seata.core.rpc.netty.ProtocolEncoder; import org.apache.seata.core.serializer.Serializer; import org.apache.seata.core.compressor.Compressor; @@ -68,12 +64,7 @@ public class ProtocolEncoderV1 extends MessageToByteEncoder implements ProtocolE private static final Logger LOGGER = LoggerFactory.getLogger(ProtocolEncoderV1.class); - @Override public void encode(RpcMessage message, ByteBuf out) { - doEncode(null, message, out); - } - - public void doEncode(ChannelHandlerContext ctx, RpcMessage message, ByteBuf out) { try { ProtocolRpcMessageV1 rpcMessage = new ProtocolRpcMessageV1(); rpcMessage.rpcMsg2ProtocolMsg(message); @@ -83,7 +74,7 @@ public void doEncode(ChannelHandlerContext ctx, RpcMessage message, ByteBuf out) byte messageType = rpcMessage.getMessageType(); out.writeBytes(ProtocolConstants.MAGIC_CODE_BYTES); - out.writeByte(ProtocolConstants.VERSION_1); + out.writeByte(protocolVersion()); // full Length(4B) and head length(2B) will fix in the end. out.writerIndex(out.writerIndex() + 6); out.writeByte(messageType); @@ -103,12 +94,7 @@ public void doEncode(ChannelHandlerContext ctx, RpcMessage message, ByteBuf out) if (messageType != ProtocolConstants.MSGTYPE_HEARTBEAT_REQUEST && messageType != ProtocolConstants.MSGTYPE_HEARTBEAT_RESPONSE) { // heartbeat has no body - String sdkVersion = ""; - if(ctx != null && ctx.channel() != null){ - sdkVersion = Version.getChannelVersion(ctx.channel()); - sdkVersion = StringUtils.isBlank(sdkVersion) ? "" : sdkVersion; - } - Serializer serializer = SerializerServiceLoader.load(SerializerType.getByCode(rpcMessage.getCodec()), sdkVersion); + Serializer serializer = SerializerServiceLoader.load(SerializerType.getByCode(rpcMessage.getCodec()), protocolVersion()); bodyBytes = serializer.serialize(rpcMessage.getBody()); Compressor compressor = CompressorFactory.getCompressor(rpcMessage.getCompressor()); bodyBytes = compressor.compress(bodyBytes); @@ -139,7 +125,7 @@ public void doEncode(ChannelHandlerContext ctx, RpcMessage message, ByteBuf out) protected void encode(ChannelHandlerContext ctx, Object msg, ByteBuf out) throws Exception { try { if (msg instanceof RpcMessage) { - this.doEncode(ctx, (RpcMessage)msg, out); + this.encode((RpcMessage)msg, out); } else { throw new UnsupportedOperationException("Not support this class:" + msg.getClass()); } @@ -148,4 +134,8 @@ protected void encode(ChannelHandlerContext ctx, Object msg, ByteBuf out) throws } } + @Override + public byte protocolVersion(){ + return ProtocolConstants.VERSION_1; + } } diff --git a/core/src/main/java/org/apache/seata/core/rpc/netty/v2/ProtocolDecoderV2.java b/core/src/main/java/org/apache/seata/core/rpc/netty/v2/ProtocolDecoderV2.java new file mode 100644 index 00000000000..fbfa5028cc4 --- /dev/null +++ b/core/src/main/java/org/apache/seata/core/rpc/netty/v2/ProtocolDecoderV2.java @@ -0,0 +1,31 @@ +/* + * 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.core.rpc.netty.v2; + +import org.apache.seata.core.protocol.ProtocolConstants; +import org.apache.seata.core.rpc.netty.v1.ProtocolDecoderV1; + +/** + * Decoder of protocol-v2 + **/ +public class ProtocolDecoderV2 extends ProtocolDecoderV1 { + + @Override + public byte protocolVersion(){ + return ProtocolConstants.VERSION_1; + } +} diff --git a/core/src/main/java/org/apache/seata/core/rpc/netty/v2/ProtocolEncoderV2.java b/core/src/main/java/org/apache/seata/core/rpc/netty/v2/ProtocolEncoderV2.java new file mode 100644 index 00000000000..7f091eb33e7 --- /dev/null +++ b/core/src/main/java/org/apache/seata/core/rpc/netty/v2/ProtocolEncoderV2.java @@ -0,0 +1,30 @@ +/* + * 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.core.rpc.netty.v2; + +import org.apache.seata.core.protocol.ProtocolConstants; +import org.apache.seata.core.rpc.netty.v1.ProtocolEncoderV1; + +/** + * Encoder of protocol-v2 + **/ +public class ProtocolEncoderV2 extends ProtocolEncoderV1 { + @Override + public byte protocolVersion(){ + return ProtocolConstants.VERSION_1; + } +} 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 af6e4d7e279..359867b5104 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 @@ -24,11 +24,9 @@ import org.apache.seata.common.loader.EnhancedServiceLoader; import org.apache.seata.common.loader.EnhancedServiceNotFoundException; import org.apache.seata.common.util.ReflectionUtil; -import org.apache.seata.common.util.StringUtils; import org.apache.seata.config.Configuration; import org.apache.seata.config.ConfigurationFactory; import org.apache.seata.core.constants.ConfigurationKeys; -import org.apache.seata.core.protocol.Version; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -68,13 +66,13 @@ private SerializerServiceLoader() { * @return the service of {@link Serializer} * @throws EnhancedServiceNotFoundException the enhanced service not found exception */ - public static Serializer load(SerializerType type, String version) throws EnhancedServiceNotFoundException { + public static Serializer load(SerializerType type, byte version) throws EnhancedServiceNotFoundException { // The following code is only used to kindly prompt users to add missing dependencies. if (type == SerializerType.PROTOBUF && !CONTAINS_PROTOBUF_DEPENDENCY) { throw new EnhancedServiceNotFoundException("The class '" + PROTOBUF_SERIALIZER_CLASS_NAME + "' not found. " + "Please manually reference 'org.apache.seata:seata-serializer-protobuf' dependency."); } - version = StringUtils.isBlank(version) ? Version.getCurrent() : version; + String key = serializerKey(type, version); Serializer serializer = SERIALIZER_MAP.get(key); if (serializer == null) { @@ -111,7 +109,7 @@ public static Serializer load(SerializerType type) throws EnhancedServiceNotFoun return serializer; } - private static String serializerKey(SerializerType type, String version) { + private static String serializerKey(SerializerType type, byte version) { if (type == SerializerType.SEATA) { return type.name() + version; } diff --git a/serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/MessageCodecFactory.java b/serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/MessageCodecFactory.java index 6231c72bbde..b17a24effd1 100644 --- a/serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/MessageCodecFactory.java +++ b/serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/MessageCodecFactory.java @@ -19,6 +19,7 @@ import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; +import org.apache.seata.core.protocol.ProtocolConstants; import org.apache.seata.serializer.seata.protocol.BatchResultMessageCodec; import org.apache.seata.serializer.seata.protocol.MergeResultMessageCodec; import org.apache.seata.serializer.seata.protocol.MergedWarpMessageCodec; @@ -77,6 +78,8 @@ import org.apache.seata.core.protocol.transaction.GlobalStatusRequest; import org.apache.seata.core.protocol.transaction.GlobalStatusResponse; import org.apache.seata.core.protocol.transaction.UndoLogDeleteRequest; +import org.apache.seata.serializer.seata.protocol.v2.RegisterRMResponseCodecV2; +import org.apache.seata.serializer.seata.protocol.v2.RegisterTMResponseCodecV2; /** * The type Message codec factory. @@ -117,13 +120,21 @@ public static MessageSeataCodec getMessageCodec(short typeCode, byte version) { msgCodec = new RegisterTMRequestCodec(); break; case MessageType.TYPE_REG_CLT_RESULT: - msgCodec = new RegisterTMResponseCodec(); + if (version == ProtocolConstants.VERSION_2) { + msgCodec = new RegisterTMResponseCodecV2(); + } else { + msgCodec = new RegisterTMResponseCodec(); + } break; case MessageType.TYPE_REG_RM: msgCodec = new RegisterRMRequestCodec(); break; case MessageType.TYPE_REG_RM_RESULT: - msgCodec = new RegisterRMResponseCodec(); + if (version == ProtocolConstants.VERSION_2) { + msgCodec = new RegisterRMResponseCodecV2(); + } else { + msgCodec = new RegisterRMResponseCodec(); + } break; case MessageType.TYPE_BRANCH_COMMIT: msgCodec = new BranchCommitRequestCodec(); diff --git a/serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/SeataSerializer.java b/serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/SeataSerializer.java index f3f7c9cf9b5..e1fb09d5154 100644 --- a/serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/SeataSerializer.java +++ b/serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/SeataSerializer.java @@ -21,16 +21,13 @@ import org.apache.seata.common.loader.LoadLevel; import org.apache.seata.common.loader.Scope; import org.apache.seata.common.util.BufferUtils; -import org.apache.seata.common.util.StringUtils; import org.apache.seata.core.protocol.AbstractMessage; -import org.apache.seata.core.protocol.IncompatibleVersionException; import org.apache.seata.core.protocol.ProtocolConstants; -import org.apache.seata.core.protocol.Version; import org.apache.seata.core.serializer.Serializer; +import org.apache.seata.serializer.seata.serializer.SeataSerializerV1; +import org.apache.seata.serializer.seata.serializer.SeataSerializerV2; import java.nio.ByteBuffer; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; /** * The Seata codec. @@ -39,11 +36,13 @@ public class SeataSerializer implements Serializer { Serializer versionSeataSerializer; - public SeataSerializer(String version) { - if (StringUtils.isBlank(version) || Version.isAboveOrEqualVersion071(version)) { - versionSeataSerializer = SeataSerializerV1.getInstance(version); - } else if (!Version.isAboveOrEqualVersion071(version)) { + public SeataSerializer(Byte version) { + if (version == ProtocolConstants.VERSION_0) { versionSeataSerializer = SeataSerializerV0.getInstance(); + } else if (version == ProtocolConstants.VERSION_1) { + versionSeataSerializer = SeataSerializerV1.getInstance(); + } else if (version == ProtocolConstants.VERSION_2) { + versionSeataSerializer = SeataSerializerV2.getInstance(); } if (versionSeataSerializer == null) { throw new UnsupportedOperationException("version is not supported"); @@ -61,65 +60,11 @@ public T deserialize(byte[] bytes) { } - static class SeataSerializerV1 implements Serializer { - - private static volatile Map instanceMap = new ConcurrentHashMap<>(); - - private String version; - - private SeataSerializerV1(String version) { - this.version = version; - } - - public static SeataSerializerV1 getInstance(String version) { - return instanceMap.computeIfAbsent(version, SeataSerializerV1::new); - } - - @Override - public byte[] serialize(T t) { - if (!(t instanceof AbstractMessage)) { - throw new IllegalArgumentException("AbstractMessage isn't available."); - } - AbstractMessage abstractMessage = (AbstractMessage) t; - //type code - short typecode = abstractMessage.getTypeCode(); - //msg codec - MessageSeataCodec messageCodec = MessageCodecFactory.getMessageCodec(typecode, ProtocolConstants.VERSION_1); - //get empty ByteBuffer - ByteBuf out = Unpooled.buffer(1024); - //msg encode - MessageSeataCodec oldCodec = MultiVersionCodecHelper.match(version, messageCodec); - messageCodec = oldCodec!=null? oldCodec : messageCodec; - - messageCodec.encode(t, out); - byte[] body = new byte[out.readableBytes()]; - out.readBytes(body); - - ByteBuffer byteBuffer; - - //typecode + body - byteBuffer = ByteBuffer.allocate(2 + body.length); - byteBuffer.putShort(typecode); - byteBuffer.put(body); - - BufferUtils.flip(byteBuffer); - byte[] content = new byte[byteBuffer.limit()]; - byteBuffer.get(content); - return content; - } - - @Override - public T deserialize(byte[] bytes) { - return deserializeByVersion(bytes, ProtocolConstants.VERSION_1, version); - } - } static class SeataSerializerV0 implements Serializer { private static volatile SeataSerializerV0 instance; - private String version = "0.7.0"; - private SeataSerializerV0() { } @@ -144,9 +89,6 @@ public byte[] serialize(T t) { short typecode = abstractMessage.getTypeCode(); //msg codec MessageSeataCodec messageCodec = MessageCodecFactory.getMessageCodec(typecode, ProtocolConstants.VERSION_0); - - MessageSeataCodec oldCodec = MultiVersionCodecHelper.match(version, messageCodec); - messageCodec = oldCodec!=null? oldCodec : messageCodec; //get empty ByteBuffer ByteBuf out = Unpooled.buffer(1024); //msg encode @@ -167,12 +109,12 @@ public byte[] serialize(T t) { @Override public T deserialize(byte[] bytes) { - return deserializeByVersion(bytes, ProtocolConstants.VERSION_0, version); + return deserializeByVersion(bytes, ProtocolConstants.VERSION_0); } } - private static T deserializeByVersion(byte[] bytes, byte protocolVersion, String version) { + public static T deserializeByVersion(byte[] bytes, byte version) { if (bytes == null || bytes.length == 0) { throw new IllegalArgumentException("Nothing to decode."); } @@ -186,10 +128,7 @@ private static T deserializeByVersion(byte[] bytes, byte protocolVersion, St //new message AbstractMessage abstractMessage = MessageCodecFactory.getMessage(typecode); //get messageCodec - MessageSeataCodec messageCodec = MessageCodecFactory.getMessageCodec(typecode, protocolVersion); - - MessageSeataCodec oldCodec = MultiVersionCodecHelper.match(version, messageCodec); - messageCodec = oldCodec != null ? oldCodec : messageCodec; + MessageSeataCodec messageCodec = MessageCodecFactory.getMessageCodec(typecode, version); //decode messageCodec.decode(abstractMessage, in); return (T) abstractMessage; diff --git a/serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/protocol/AbstractIdentifyResponseCodec.java b/serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/protocol/AbstractIdentifyResponseCodec.java index e40a05e5f0f..56840f9e618 100644 --- a/serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/protocol/AbstractIdentifyResponseCodec.java +++ b/serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/protocol/AbstractIdentifyResponseCodec.java @@ -34,7 +34,6 @@ public Class getMessageClassType() { @Override public void encode(T t, ByteBuf out) { - super.encode(t, out); AbstractIdentifyResponse abstractIdentifyResponse = (AbstractIdentifyResponse)t; boolean identified = abstractIdentifyResponse.isIdentified(); String version = abstractIdentifyResponse.getVersion(); @@ -53,7 +52,6 @@ public void encode(T t, ByteBuf out) { @Override public void decode(T t, ByteBuffer in) { - super.decode(t, in); AbstractIdentifyResponse abstractIdentifyResponse = (AbstractIdentifyResponse)t; abstractIdentifyResponse.setIdentified(in.get() == 1); diff --git a/serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/protocol/RegisterRMResponseCodec.java b/serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/protocol/RegisterRMResponseCodec.java index 31f311f273f..41738263166 100644 --- a/serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/protocol/RegisterRMResponseCodec.java +++ b/serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/protocol/RegisterRMResponseCodec.java @@ -16,73 +16,16 @@ */ package org.apache.seata.serializer.seata.protocol; -import io.netty.buffer.ByteBuf; -import org.apache.seata.core.protocol.AbstractIdentifyResponse; import org.apache.seata.core.protocol.RegisterRMResponse; -import org.apache.seata.serializer.seata.MessageSeataCodec; -import org.apache.seata.serializer.seata.MultiVersionCodec; - -import java.nio.ByteBuffer; -import java.util.Collections; -import java.util.Map; /** * The type Register rm response codec. + * */ -public class RegisterRMResponseCodec extends AbstractIdentifyResponseCodec implements MultiVersionCodec { +public class RegisterRMResponseCodec extends AbstractIdentifyResponseCodec { @Override public Class getMessageClassType() { return RegisterRMResponse.class; } - - - @Override - public Map oldVersionCodec() { - return Collections.singletonMap( - // todo 【所谓旧版本的范围,这个在版本发布之前都不容易确定】 - new MultiVersionCodec.VersionRange("2.1.0"), - new MessageSeataCodec() { - @Override - public Class getMessageClassType() { - return RegisterRMResponseCodec.this.getMessageClassType(); - } - - @Override - public void encode(T t, ByteBuf out) { - AbstractIdentifyResponse abstractIdentifyResponse = (AbstractIdentifyResponse) t; - boolean identified = abstractIdentifyResponse.isIdentified(); - String version = abstractIdentifyResponse.getVersion(); - - out.writeByte(identified ? (byte) 1 : (byte) 0); - if (version != null) { - byte[] bs = version.getBytes(UTF8); - out.writeShort((short) bs.length); - if (bs.length > 0) { - out.writeBytes(bs); - } - } else { - out.writeShort((short) 0); - } - } - - @Override - public void decode(T t, ByteBuffer in) { - AbstractIdentifyResponse abstractIdentifyResponse = (AbstractIdentifyResponse) t; - - abstractIdentifyResponse.setIdentified(in.get() == 1); - short len = in.getShort(); - if (len <= 0) { - return; - } - if (in.remaining() < len) { - return; - } - byte[] bs = new byte[len]; - in.get(bs); - abstractIdentifyResponse.setVersion(new String(bs, UTF8)); - } - } - ); - } } diff --git a/serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/protocol/RegisterTMResponseCodec.java b/serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/protocol/RegisterTMResponseCodec.java index 9af2aed43a4..093fac34e18 100644 --- a/serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/protocol/RegisterTMResponseCodec.java +++ b/serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/protocol/RegisterTMResponseCodec.java @@ -17,73 +17,17 @@ package org.apache.seata.serializer.seata.protocol; -import io.netty.buffer.ByteBuf; -import org.apache.seata.core.protocol.AbstractIdentifyResponse; import org.apache.seata.core.protocol.RegisterTMResponse; -import org.apache.seata.serializer.seata.MessageSeataCodec; -import org.apache.seata.serializer.seata.MultiVersionCodec; - -import java.nio.ByteBuffer; -import java.util.Collections; -import java.util.Map; /** * The type Register tm response codec. * */ -public class RegisterTMResponseCodec extends AbstractIdentifyResponseCodec implements MultiVersionCodec { +public class RegisterTMResponseCodec extends AbstractIdentifyResponseCodec { @Override public Class getMessageClassType() { return RegisterTMResponse.class; } - @Override - public Map oldVersionCodec() { - return Collections.singletonMap( - // todo 【所谓旧版本的范围,这个在版本发布之前都不容易确定】 - new MultiVersionCodec.VersionRange("2.1.0"), - new MessageSeataCodec() { - @Override - public Class getMessageClassType() { - return RegisterTMResponseCodec.this.getMessageClassType(); - } - - @Override - public void encode(T t, ByteBuf out) { - AbstractIdentifyResponse abstractIdentifyResponse = (AbstractIdentifyResponse)t; - boolean identified = abstractIdentifyResponse.isIdentified(); - String version = abstractIdentifyResponse.getVersion(); - - out.writeByte(identified ? (byte)1 : (byte)0); - if (version != null) { - byte[] bs = version.getBytes(UTF8); - out.writeShort((short)bs.length); - if (bs.length > 0) { - out.writeBytes(bs); - } - } else { - out.writeShort((short)0); - } - } - - @Override - public void decode(T t, ByteBuffer in) { - AbstractIdentifyResponse abstractIdentifyResponse = (AbstractIdentifyResponse)t; - - abstractIdentifyResponse.setIdentified(in.get() == 1); - short len = in.getShort(); - if (len <= 0) { - return; - } - if (in.remaining() < len) { - return; - } - byte[] bs = new byte[len]; - in.get(bs); - abstractIdentifyResponse.setVersion(new String(bs, UTF8)); - } - } - ); - } } diff --git a/serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/protocol/v2/AbstractIdentifyResponseCodecV2.java b/serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/protocol/v2/AbstractIdentifyResponseCodecV2.java new file mode 100644 index 00000000000..c74d9bea35f --- /dev/null +++ b/serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/protocol/v2/AbstractIdentifyResponseCodecV2.java @@ -0,0 +1,55 @@ +package org.apache.seata.serializer.seata.protocol.v2; + +import io.netty.buffer.ByteBuf; +import org.apache.seata.core.protocol.AbstractIdentifyResponse; +import org.apache.seata.serializer.seata.protocol.AbstractResultMessageCodec; + +import java.nio.ByteBuffer; + +/** + * The type Abstract identify request codec.(v2) + **/ +public class AbstractIdentifyResponseCodecV2 extends AbstractResultMessageCodec { + @Override + public Class getMessageClassType() { + return AbstractIdentifyResponse.class; + } + + @Override + public void encode(T t, ByteBuf out) { + super.encode(t, out); + AbstractIdentifyResponse abstractIdentifyResponse = (AbstractIdentifyResponse) t; + boolean identified = abstractIdentifyResponse.isIdentified(); + String version = abstractIdentifyResponse.getVersion(); + + out.writeByte(identified ? (byte) 1 : (byte) 0); + if (version != null) { + byte[] bs = version.getBytes(UTF8); + out.writeShort((short) bs.length); + if (bs.length > 0) { + out.writeBytes(bs); + } + } else { + out.writeShort((short) 0); + } + } + + @Override + public void decode(T t, ByteBuffer in) { + super.decode(t, in); + AbstractIdentifyResponse abstractIdentifyResponse = (AbstractIdentifyResponse) t; + + abstractIdentifyResponse.setIdentified(in.get() == 1); + short len = in.getShort(); + if (len <= 0) { + return; + } + if (in.remaining() < len) { + return; + } + byte[] bs = new byte[len]; + in.get(bs); + abstractIdentifyResponse.setVersion(new String(bs, UTF8)); + } + +} diff --git a/serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/protocol/v2/RegisterRMResponseCodecV2.java b/serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/protocol/v2/RegisterRMResponseCodecV2.java new file mode 100644 index 00000000000..6f9b1c2f1dd --- /dev/null +++ b/serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/protocol/v2/RegisterRMResponseCodecV2.java @@ -0,0 +1,32 @@ +/* + * 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.seata.protocol.v2; + +import org.apache.seata.core.protocol.RegisterRMResponse; + +/** + * The type Register rm response codec.(v2) + */ +public class RegisterRMResponseCodecV2 extends AbstractIdentifyResponseCodecV2 { + + @Override + public Class getMessageClassType() { + return RegisterRMResponse.class; + } + + +} diff --git a/serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/protocol/v2/RegisterTMResponseCodecV2.java b/serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/protocol/v2/RegisterTMResponseCodecV2.java new file mode 100644 index 00000000000..17a238d2f30 --- /dev/null +++ b/serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/protocol/v2/RegisterTMResponseCodecV2.java @@ -0,0 +1,32 @@ +/* + * 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.seata.protocol.v2; + + +import org.apache.seata.core.protocol.RegisterTMResponse; + +/** + * The type Register tm response codec.(v2) + */ +public class RegisterTMResponseCodecV2 extends AbstractIdentifyResponseCodecV2 { + + @Override + public Class getMessageClassType() { + return RegisterTMResponse.class; + } + +} diff --git a/serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/serializer/SeataSerializerV1.java b/serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/serializer/SeataSerializerV1.java new file mode 100644 index 00000000000..46d5b43a712 --- /dev/null +++ b/serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/serializer/SeataSerializerV1.java @@ -0,0 +1,74 @@ +package org.apache.seata.serializer.seata.serializer; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import org.apache.seata.common.util.BufferUtils; +import org.apache.seata.core.protocol.AbstractMessage; +import org.apache.seata.core.protocol.ProtocolConstants; +import org.apache.seata.core.serializer.Serializer; +import org.apache.seata.serializer.seata.MessageCodecFactory; +import org.apache.seata.serializer.seata.MessageSeataCodec; +import org.apache.seata.serializer.seata.SeataSerializer; + +import java.nio.ByteBuffer; + +/** + * SeataSerializer of V1 + **/ +public class SeataSerializerV1 implements Serializer { + + private static volatile SeataSerializerV1 instance; + + protected SeataSerializerV1() { + } + + public static SeataSerializerV1 getInstance() { + if (instance == null) { + synchronized (SeataSerializerV1.class) { + if (instance == null) { + instance = new SeataSerializerV1(); + } + } + } + return instance; + } + + @Override + public byte[] serialize(T t) { + if (!(t instanceof AbstractMessage)) { + throw new IllegalArgumentException("AbstractMessage isn't available."); + } + AbstractMessage abstractMessage = (AbstractMessage) t; + //type code + short typecode = abstractMessage.getTypeCode(); + //msg codec + MessageSeataCodec messageCodec = MessageCodecFactory.getMessageCodec(typecode, protocolVersion()); + //get empty ByteBuffer + ByteBuf out = Unpooled.buffer(1024); + //msg encode + messageCodec.encode(t, out); + byte[] body = new byte[out.readableBytes()]; + out.readBytes(body); + + ByteBuffer byteBuffer; + + //typecode + body + byteBuffer = ByteBuffer.allocate(2 + body.length); + byteBuffer.putShort(typecode); + byteBuffer.put(body); + + BufferUtils.flip(byteBuffer); + byte[] content = new byte[byteBuffer.limit()]; + byteBuffer.get(content); + return content; + } + + @Override + public T deserialize(byte[] bytes) { + return SeataSerializer.deserializeByVersion(bytes, protocolVersion()); + } + + public byte protocolVersion(){ + return ProtocolConstants.VERSION_1; + } +} diff --git a/serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/serializer/SeataSerializerV2.java b/serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/serializer/SeataSerializerV2.java new file mode 100644 index 00000000000..7f8f9049b87 --- /dev/null +++ b/serializer/seata-serializer-seata/src/main/java/org/apache/seata/serializer/seata/serializer/SeataSerializerV2.java @@ -0,0 +1,31 @@ +package org.apache.seata.serializer.seata.serializer; + +import org.apache.seata.core.protocol.ProtocolConstants; + +/** + * ? + * + * @author minghua.xie + * @date 2024/11/26 + **/ +public class SeataSerializerV2 extends SeataSerializerV1{ + private static volatile SeataSerializerV2 instance; + + protected SeataSerializerV2() { + } + + public static SeataSerializerV1 getInstance() { + if (instance == null) { + synchronized (SeataSerializerV2.class) { + if (instance == null) { + instance = new SeataSerializerV2(); + } + } + } + return instance; + } + + public byte protocolVersion(){ + return ProtocolConstants.VERSION_2; + } +} diff --git a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/BatchResultMessageSerializerTest.java b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/BatchResultMessageSerializerTest.java index 350e4cd90bf..ca7ab1a4340 100644 --- a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/BatchResultMessageSerializerTest.java +++ b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/BatchResultMessageSerializerTest.java @@ -22,9 +22,8 @@ import org.apache.seata.core.model.BranchStatus; import org.apache.seata.core.protocol.AbstractResultMessage; import org.apache.seata.core.protocol.BatchResultMessage; -import org.apache.seata.core.protocol.Version; +import org.apache.seata.core.protocol.ProtocolConstants; import org.apache.seata.core.protocol.ResultCode; -import org.apache.seata.core.protocol.Version; import org.apache.seata.core.protocol.transaction.BranchCommitResponse; import org.apache.seata.serializer.seata.SeataSerializer; import org.junit.jupiter.api.Test; @@ -41,7 +40,8 @@ public class BatchResultMessageSerializerTest { /** * The Seata codec. */ - SeataSerializer seataSerializer = new SeataSerializer(Version.getCurrent()); + SeataSerializer seataSerializer = new SeataSerializer(ProtocolConstants.VERSION); + @Test public void testCodec() { diff --git a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/MergeResultMessageSerializerTest.java b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/MergeResultMessageSerializerTest.java index 9793be672ac..b777710058b 100644 --- a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/MergeResultMessageSerializerTest.java +++ b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/MergeResultMessageSerializerTest.java @@ -23,7 +23,7 @@ import org.apache.seata.core.protocol.ResultCode; import org.apache.seata.core.protocol.transaction.GlobalBeginResponse; import org.junit.jupiter.api.Test; -import org.apache.seata.core.protocol.Version; +import org.apache.seata.core.protocol.ProtocolConstants; import static org.assertj.core.api.Assertions.assertThat; /** @@ -35,7 +35,7 @@ public class MergeResultMessageSerializerTest { /** * The Seata codec. */ - SeataSerializer seataSerializer = new SeataSerializer(Version.getCurrent()); + SeataSerializer seataSerializer = new SeataSerializer(ProtocolConstants.VERSION); /** * Test codec. diff --git a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/MergedWarpMessageSerializerTest.java b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/MergedWarpMessageSerializerTest.java index 13645725b23..98cce56632f 100644 --- a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/MergedWarpMessageSerializerTest.java +++ b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/MergedWarpMessageSerializerTest.java @@ -21,11 +21,10 @@ import org.apache.seata.core.protocol.AbstractMessage; import org.apache.seata.core.protocol.MergedWarpMessage; -import org.apache.seata.core.protocol.Version; import org.apache.seata.core.protocol.transaction.GlobalBeginRequest; import org.apache.seata.serializer.seata.SeataSerializer; import org.junit.jupiter.api.Test; -import org.apache.seata.core.protocol.Version; +import org.apache.seata.core.protocol.ProtocolConstants; import static org.assertj.core.api.Assertions.assertThat; @@ -38,7 +37,7 @@ public class MergedWarpMessageSerializerTest { /** * The Seata codec. */ - SeataSerializer seataSerializer = new SeataSerializer(Version.getCurrent()); + SeataSerializer seataSerializer = new SeataSerializer(ProtocolConstants.VERSION); /** * Test codec. diff --git a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/RegisterRMRequestSerializerTest.java b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/RegisterRMRequestSerializerTest.java index c1539c4f608..b469bada982 100644 --- a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/RegisterRMRequestSerializerTest.java +++ b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/RegisterRMRequestSerializerTest.java @@ -19,7 +19,7 @@ import org.apache.seata.serializer.seata.SeataSerializer; import org.apache.seata.core.protocol.RegisterRMRequest; import org.junit.jupiter.api.Test; -import org.apache.seata.core.protocol.Version; +import org.apache.seata.core.protocol.ProtocolConstants; import static org.assertj.core.api.Assertions.assertThat; /** @@ -31,7 +31,7 @@ public class RegisterRMRequestSerializerTest { /** * The Seata codec. */ - SeataSerializer seataSerializer = new SeataSerializer(Version.getCurrent()); + SeataSerializer seataSerializer = new SeataSerializer(ProtocolConstants.VERSION); /** * Test codec. diff --git a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/RegisterRMResponseSerializerTest.java b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/RegisterRMResponseSerializerTest.java index ab1704ef7a5..c766eb203a1 100644 --- a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/RegisterRMResponseSerializerTest.java +++ b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/RegisterRMResponseSerializerTest.java @@ -20,7 +20,7 @@ import org.apache.seata.core.protocol.RegisterRMResponse; import org.apache.seata.core.protocol.ResultCode; import org.junit.jupiter.api.Test; -import org.apache.seata.core.protocol.Version; +import org.apache.seata.core.protocol.ProtocolConstants; import static org.assertj.core.api.Assertions.assertThat; @@ -33,7 +33,7 @@ public class RegisterRMResponseSerializerTest { /** * The Seata codec. */ - SeataSerializer seataSerializer = new SeataSerializer(Version.getCurrent()); + SeataSerializer seataSerializer = new SeataSerializer(ProtocolConstants.VERSION); /** * Test codec. diff --git a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/RegisterTMRequestSerializerTest.java b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/RegisterTMRequestSerializerTest.java index 77e343b1f9f..73c53e89ae2 100644 --- a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/RegisterTMRequestSerializerTest.java +++ b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/RegisterTMRequestSerializerTest.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.mockito.Mockito; -import org.apache.seata.core.protocol.Version; +import org.apache.seata.core.protocol.ProtocolConstants; import static io.netty.buffer.Unpooled.buffer; import static org.assertj.core.api.Assertions.assertThat; @@ -37,7 +37,7 @@ public class RegisterTMRequestSerializerTest { /** * The Seata codec. */ - SeataSerializer seataSerializer = new SeataSerializer(Version.getCurrent()); + SeataSerializer seataSerializer = new SeataSerializer(ProtocolConstants.VERSION); private static RegisterTMRequest registerTMRequest; private static AbstractIdentifyRequest air; diff --git a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/RegisterTMResponseSerializerTest.java b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/RegisterTMResponseSerializerTest.java index 77966801784..b2cbb88235d 100644 --- a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/RegisterTMResponseSerializerTest.java +++ b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/RegisterTMResponseSerializerTest.java @@ -20,7 +20,7 @@ import org.apache.seata.core.protocol.RegisterTMResponse; import org.apache.seata.core.protocol.ResultCode; import org.junit.jupiter.api.Test; -import org.apache.seata.core.protocol.Version; +import org.apache.seata.core.protocol.ProtocolConstants; import static org.assertj.core.api.Assertions.assertThat; /** @@ -32,7 +32,7 @@ public class RegisterTMResponseSerializerTest { /** * The Seata codec. */ - SeataSerializer seataSerializer = new SeataSerializer(Version.getCurrent()); + SeataSerializer seataSerializer = new SeataSerializer(ProtocolConstants.VERSION); /** * Test codec. diff --git a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/BranchCommitRequestSerializerTest.java b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/BranchCommitRequestSerializerTest.java index 6ec220672ba..fa66b63a35c 100644 --- a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/BranchCommitRequestSerializerTest.java +++ b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/BranchCommitRequestSerializerTest.java @@ -16,7 +16,7 @@ */ package org.apache.seata.serializer.seata.protocol.transaction; -import org.apache.seata.core.protocol.Version; +import org.apache.seata.core.protocol.ProtocolConstants; import org.apache.seata.serializer.seata.SeataSerializer; import org.apache.seata.core.model.BranchType; import org.apache.seata.core.protocol.transaction.BranchCommitRequest; @@ -33,7 +33,7 @@ public class BranchCommitRequestSerializerTest { /** * The Seata codec. */ - SeataSerializer seataSerializer = new SeataSerializer(Version.getCurrent()); + SeataSerializer seataSerializer = new SeataSerializer(ProtocolConstants.VERSION); /** * Test codec. diff --git a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/BranchCommitResponseSerializerTest.java b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/BranchCommitResponseSerializerTest.java index 8e9b8f66a43..d16ccbfa108 100644 --- a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/BranchCommitResponseSerializerTest.java +++ b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/BranchCommitResponseSerializerTest.java @@ -16,7 +16,7 @@ */ package org.apache.seata.serializer.seata.protocol.transaction; -import org.apache.seata.core.protocol.Version; +import org.apache.seata.core.protocol.ProtocolConstants; import org.apache.seata.serializer.seata.SeataSerializer; import org.apache.seata.core.exception.TransactionExceptionCode; import org.apache.seata.core.model.BranchStatus; @@ -35,7 +35,7 @@ public class BranchCommitResponseSerializerTest { /** * The Seata codec. */ - SeataSerializer seataSerializer = new SeataSerializer(Version.getCurrent()); + SeataSerializer seataSerializer = new SeataSerializer(ProtocolConstants.VERSION); /** * Test codec. diff --git a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/BranchRegisterRequestSerializerTest.java b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/BranchRegisterRequestSerializerTest.java index 74c5d05bae2..dd18665a461 100644 --- a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/BranchRegisterRequestSerializerTest.java +++ b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/BranchRegisterRequestSerializerTest.java @@ -16,7 +16,7 @@ */ package org.apache.seata.serializer.seata.protocol.transaction; -import org.apache.seata.core.protocol.Version; +import org.apache.seata.core.protocol.ProtocolConstants; import org.apache.seata.serializer.seata.SeataSerializer; import org.apache.seata.core.model.BranchType; import org.apache.seata.core.protocol.transaction.BranchRegisterRequest; @@ -33,7 +33,7 @@ public class BranchRegisterRequestSerializerTest { /** * The Seata codec. */ - SeataSerializer seataSerializer = new SeataSerializer(Version.getCurrent()); + SeataSerializer seataSerializer = new SeataSerializer(ProtocolConstants.VERSION); /** * Test codec. diff --git a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/BranchRegisterResponseSerializerTest.java b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/BranchRegisterResponseSerializerTest.java index 3067312e2a0..d10bf6f09af 100644 --- a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/BranchRegisterResponseSerializerTest.java +++ b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/BranchRegisterResponseSerializerTest.java @@ -16,7 +16,7 @@ */ package org.apache.seata.serializer.seata.protocol.transaction; -import org.apache.seata.core.protocol.Version; +import org.apache.seata.core.protocol.ProtocolConstants; import org.apache.seata.serializer.seata.SeataSerializer; import org.apache.seata.core.exception.TransactionExceptionCode; import org.apache.seata.core.protocol.ResultCode; @@ -34,7 +34,7 @@ public class BranchRegisterResponseSerializerTest { /** * The Seata codec. */ - SeataSerializer seataSerializer = new SeataSerializer(Version.getCurrent()); + SeataSerializer seataSerializer = new SeataSerializer(ProtocolConstants.VERSION); /** * Test codec. diff --git a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/BranchReportRequestSerializerTest.java b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/BranchReportRequestSerializerTest.java index f9eac116138..0ea5c0d36f6 100644 --- a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/BranchReportRequestSerializerTest.java +++ b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/BranchReportRequestSerializerTest.java @@ -16,7 +16,7 @@ */ package org.apache.seata.serializer.seata.protocol.transaction; -import org.apache.seata.core.protocol.Version; +import org.apache.seata.core.protocol.ProtocolConstants; import org.apache.seata.serializer.seata.SeataSerializer; import org.apache.seata.core.model.BranchStatus; import org.apache.seata.core.model.BranchType; @@ -34,7 +34,7 @@ public class BranchReportRequestSerializerTest { /** * The Seata codec. */ - SeataSerializer seataSerializer = new SeataSerializer(Version.getCurrent()); + SeataSerializer seataSerializer = new SeataSerializer(ProtocolConstants.VERSION); /** * Test codec. diff --git a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/BranchReportResponseSerializerTest.java b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/BranchReportResponseSerializerTest.java index 25e3886a4e8..2a1fea6cbff 100644 --- a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/BranchReportResponseSerializerTest.java +++ b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/BranchReportResponseSerializerTest.java @@ -16,7 +16,7 @@ */ package org.apache.seata.serializer.seata.protocol.transaction; -import org.apache.seata.core.protocol.Version; +import org.apache.seata.core.protocol.ProtocolConstants; import org.apache.seata.serializer.seata.SeataSerializer; import org.apache.seata.core.exception.TransactionExceptionCode; import org.apache.seata.core.protocol.ResultCode; @@ -34,7 +34,7 @@ public class BranchReportResponseSerializerTest { /** * The Seata codec. */ - SeataSerializer seataSerializer = new SeataSerializer(Version.getCurrent()); + SeataSerializer seataSerializer = new SeataSerializer(ProtocolConstants.VERSION); /** * Test codec. diff --git a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/BranchRollbackRequestSerializerTest.java b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/BranchRollbackRequestSerializerTest.java index 3aa2ba8f7bf..a73f623a1d3 100644 --- a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/BranchRollbackRequestSerializerTest.java +++ b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/BranchRollbackRequestSerializerTest.java @@ -16,7 +16,7 @@ */ package org.apache.seata.serializer.seata.protocol.transaction; -import org.apache.seata.core.protocol.Version; +import org.apache.seata.core.protocol.ProtocolConstants; import org.apache.seata.serializer.seata.SeataSerializer; import org.apache.seata.core.model.BranchType; import org.apache.seata.core.protocol.transaction.BranchRollbackRequest; @@ -33,7 +33,7 @@ public class BranchRollbackRequestSerializerTest { /** * The Seata codec. */ - SeataSerializer seataSerializer = new SeataSerializer(Version.getCurrent()); + SeataSerializer seataSerializer = new SeataSerializer(ProtocolConstants.VERSION); /** * Test codec. diff --git a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/BranchRollbackResponseSerializerTest.java b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/BranchRollbackResponseSerializerTest.java index 75d13a98275..629ec6a4c2e 100644 --- a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/BranchRollbackResponseSerializerTest.java +++ b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/BranchRollbackResponseSerializerTest.java @@ -16,7 +16,7 @@ */ package org.apache.seata.serializer.seata.protocol.transaction; -import org.apache.seata.core.protocol.Version; +import org.apache.seata.core.protocol.ProtocolConstants; import org.apache.seata.serializer.seata.SeataSerializer; import org.apache.seata.core.exception.TransactionExceptionCode; import org.apache.seata.core.model.BranchStatus; @@ -35,7 +35,7 @@ public class BranchRollbackResponseSerializerTest { /** * The Seata codec. */ - SeataSerializer seataSerializer = new SeataSerializer(Version.getCurrent()); + SeataSerializer seataSerializer = new SeataSerializer(ProtocolConstants.VERSION); /** * Test codec. diff --git a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalBeginRequestSerializerTest.java b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalBeginRequestSerializerTest.java index 996c9998727..16cd14a8d82 100644 --- a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalBeginRequestSerializerTest.java +++ b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalBeginRequestSerializerTest.java @@ -16,7 +16,7 @@ */ package org.apache.seata.serializer.seata.protocol.transaction; -import org.apache.seata.core.protocol.Version; +import org.apache.seata.core.protocol.ProtocolConstants; import org.apache.seata.serializer.seata.SeataSerializer; import org.apache.seata.core.protocol.transaction.GlobalBeginRequest; import org.junit.jupiter.api.Test; @@ -32,7 +32,7 @@ public class GlobalBeginRequestSerializerTest { /** * The Seata codec. */ - SeataSerializer seataSerializer = new SeataSerializer(Version.getCurrent()); + SeataSerializer seataSerializer = new SeataSerializer(ProtocolConstants.VERSION); /** * Test codec. diff --git a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalBeginResponseSerializerTest.java b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalBeginResponseSerializerTest.java index cc79deebabc..c3bb00f93b3 100644 --- a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalBeginResponseSerializerTest.java +++ b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalBeginResponseSerializerTest.java @@ -16,7 +16,7 @@ */ package org.apache.seata.serializer.seata.protocol.transaction; -import org.apache.seata.core.protocol.Version; +import org.apache.seata.core.protocol.ProtocolConstants; import org.apache.seata.serializer.seata.SeataSerializer; import org.apache.seata.core.exception.TransactionExceptionCode; import org.apache.seata.core.protocol.ResultCode; @@ -33,7 +33,7 @@ public class GlobalBeginResponseSerializerTest { /** * The Seata codec. */ - SeataSerializer seataSerializer = new SeataSerializer(Version.getCurrent()); + SeataSerializer seataSerializer = new SeataSerializer(ProtocolConstants.VERSION); /** * Test codec. diff --git a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalCommitRequestCodecTest.java b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalCommitRequestCodecTest.java index a2d8440c77e..502d4db7001 100644 --- a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalCommitRequestCodecTest.java +++ b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalCommitRequestCodecTest.java @@ -16,7 +16,7 @@ */ package org.apache.seata.serializer.seata.protocol.transaction; -import org.apache.seata.core.protocol.Version; +import org.apache.seata.core.protocol.ProtocolConstants; import org.apache.seata.serializer.seata.SeataSerializer; import org.apache.seata.core.protocol.transaction.GlobalCommitRequest; import org.junit.jupiter.api.Test; @@ -32,7 +32,7 @@ public class GlobalCommitRequestCodecTest { /** * The Seata codec. */ - SeataSerializer seataSerializer = new SeataSerializer(Version.getCurrent()); + SeataSerializer seataSerializer = new SeataSerializer(ProtocolConstants.VERSION); /** * Test codec. diff --git a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalCommitResponseSerializerTest.java b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalCommitResponseSerializerTest.java index 8d68acc1f68..d9f2f2e8d9f 100644 --- a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalCommitResponseSerializerTest.java +++ b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalCommitResponseSerializerTest.java @@ -16,7 +16,7 @@ */ package org.apache.seata.serializer.seata.protocol.transaction; -import org.apache.seata.core.protocol.Version; +import org.apache.seata.core.protocol.ProtocolConstants; import org.apache.seata.serializer.seata.SeataSerializer; import org.apache.seata.core.exception.TransactionExceptionCode; import org.apache.seata.core.model.GlobalStatus; @@ -34,7 +34,7 @@ public class GlobalCommitResponseSerializerTest { /** * The Seata codec. */ - SeataSerializer seataSerializer = new SeataSerializer(Version.getCurrent()); + SeataSerializer seataSerializer = new SeataSerializer(ProtocolConstants.VERSION); /** * Test codec. diff --git a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalLockQueryRequestSerializerTest.java b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalLockQueryRequestSerializerTest.java index 73a95271e67..be9a494f790 100644 --- a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalLockQueryRequestSerializerTest.java +++ b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalLockQueryRequestSerializerTest.java @@ -16,7 +16,7 @@ */ package org.apache.seata.serializer.seata.protocol.transaction; -import org.apache.seata.core.protocol.Version; +import org.apache.seata.core.protocol.ProtocolConstants; import org.apache.seata.serializer.seata.SeataSerializer; import org.apache.seata.core.model.BranchType; import org.apache.seata.core.protocol.transaction.GlobalLockQueryRequest; @@ -32,7 +32,7 @@ public class GlobalLockQueryRequestSerializerTest { /** * The Seata codec. */ - SeataSerializer seataSerializer = new SeataSerializer(Version.getCurrent()); + SeataSerializer seataSerializer = new SeataSerializer(ProtocolConstants.VERSION); /** * Test codec. diff --git a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalLockQueryResponseSerializerTest.java b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalLockQueryResponseSerializerTest.java index cfae19cc9ae..1761a11c941 100644 --- a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalLockQueryResponseSerializerTest.java +++ b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalLockQueryResponseSerializerTest.java @@ -16,7 +16,7 @@ */ package org.apache.seata.serializer.seata.protocol.transaction; -import org.apache.seata.core.protocol.Version; +import org.apache.seata.core.protocol.ProtocolConstants; import org.apache.seata.serializer.seata.SeataSerializer; import org.apache.seata.core.exception.TransactionExceptionCode; import org.apache.seata.core.protocol.ResultCode; @@ -34,7 +34,7 @@ public class GlobalLockQueryResponseSerializerTest { /** * The Seata codec. */ - SeataSerializer seataSerializer = new SeataSerializer(Version.getCurrent()); + SeataSerializer seataSerializer = new SeataSerializer(ProtocolConstants.VERSION); /** * Test codec. diff --git a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalRollbackRequestCodecTest.java b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalRollbackRequestCodecTest.java index d2f75068eb6..204bafa692d 100644 --- a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalRollbackRequestCodecTest.java +++ b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalRollbackRequestCodecTest.java @@ -16,7 +16,7 @@ */ package org.apache.seata.serializer.seata.protocol.transaction; -import org.apache.seata.core.protocol.Version; +import org.apache.seata.core.protocol.ProtocolConstants; import org.apache.seata.serializer.seata.SeataSerializer; import org.apache.seata.core.protocol.transaction.GlobalRollbackRequest; import org.junit.jupiter.api.Test; @@ -32,7 +32,7 @@ public class GlobalRollbackRequestCodecTest { /** * The Seata codec. */ - SeataSerializer seataSerializer = new SeataSerializer(Version.getCurrent()); + SeataSerializer seataSerializer = new SeataSerializer(ProtocolConstants.VERSION); /** * Test codec. diff --git a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalRollbackResponseSerializerTest.java b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalRollbackResponseSerializerTest.java index e40cace909e..084cbc62c56 100644 --- a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalRollbackResponseSerializerTest.java +++ b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalRollbackResponseSerializerTest.java @@ -16,7 +16,7 @@ */ package org.apache.seata.serializer.seata.protocol.transaction; -import org.apache.seata.core.protocol.Version; +import org.apache.seata.core.protocol.ProtocolConstants; import org.apache.seata.serializer.seata.SeataSerializer; import org.apache.seata.core.exception.TransactionExceptionCode; import org.apache.seata.core.model.GlobalStatus; @@ -35,7 +35,7 @@ public class GlobalRollbackResponseSerializerTest { /** * The Seata codec. */ - SeataSerializer seataSerializer = new SeataSerializer(Version.getCurrent()); + SeataSerializer seataSerializer = new SeataSerializer(ProtocolConstants.VERSION); /** * Test codec. diff --git a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalStatusRequestCodecTest.java b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalStatusRequestCodecTest.java index 52b077bbbf4..0ea3bbba80d 100644 --- a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalStatusRequestCodecTest.java +++ b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalStatusRequestCodecTest.java @@ -16,7 +16,7 @@ */ package org.apache.seata.serializer.seata.protocol.transaction; -import org.apache.seata.core.protocol.Version; +import org.apache.seata.core.protocol.ProtocolConstants; import org.apache.seata.serializer.seata.SeataSerializer; import org.apache.seata.core.protocol.transaction.GlobalStatusRequest; import org.junit.jupiter.api.Test; @@ -32,7 +32,7 @@ public class GlobalStatusRequestCodecTest { /** * The Seata codec. */ - SeataSerializer seataSerializer = new SeataSerializer(Version.getCurrent()); + SeataSerializer seataSerializer = new SeataSerializer(ProtocolConstants.VERSION); /** * Test codec. diff --git a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalStatusResponseSerializerTest.java b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalStatusResponseSerializerTest.java index 6793112fed2..9122db6d3ee 100644 --- a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalStatusResponseSerializerTest.java +++ b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/GlobalStatusResponseSerializerTest.java @@ -16,7 +16,7 @@ */ package org.apache.seata.serializer.seata.protocol.transaction; -import org.apache.seata.core.protocol.Version; +import org.apache.seata.core.protocol.ProtocolConstants; import org.apache.seata.serializer.seata.SeataSerializer; import org.apache.seata.core.exception.TransactionExceptionCode; import org.apache.seata.core.model.GlobalStatus; @@ -34,7 +34,7 @@ public class GlobalStatusResponseSerializerTest { /** * The Seata codec. */ - SeataSerializer seataSerializer = new SeataSerializer(Version.getCurrent()); + SeataSerializer seataSerializer = new SeataSerializer(ProtocolConstants.VERSION); /** * Test codec. diff --git a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/UndoLogDeleteRequestSerializerTest.java b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/UndoLogDeleteRequestSerializerTest.java index 740e1cc2e08..17ff921034b 100644 --- a/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/UndoLogDeleteRequestSerializerTest.java +++ b/serializer/seata-serializer-seata/src/test/java/org/apache/seata/serializer/seata/protocol/transaction/UndoLogDeleteRequestSerializerTest.java @@ -16,7 +16,7 @@ */ package org.apache.seata.serializer.seata.protocol.transaction; -import org.apache.seata.core.protocol.Version; +import org.apache.seata.core.protocol.ProtocolConstants; import org.apache.seata.serializer.seata.SeataSerializer; import org.apache.seata.core.model.BranchType; import org.apache.seata.core.protocol.transaction.UndoLogDeleteRequest; @@ -33,7 +33,7 @@ public class UndoLogDeleteRequestSerializerTest { /** * The Seata codec. */ - SeataSerializer seataSerializer = new SeataSerializer(Version.getCurrent()); + SeataSerializer seataSerializer = new SeataSerializer(ProtocolConstants.VERSION); /** * Test codec.