This is an automated email from the ASF dual-hosted git repository. songxiaosheng pushed a commit to branch 3.3 in repository https://gitbox.apache.org/repos/asf/dubbo-spi-extensions.git
The following commit(s) were added to refs/heads/3.3 by this push: new 55e2bdc7 Add ser units (#440) 55e2bdc7 is described below commit 55e2bdc7607b51cb28543ed01362f2c2dfef1ee2 Author: 王聪洋 <56506697+wcy666...@users.noreply.github.com> AuthorDate: Sun Jul 7 18:16:28 2024 +0800 Add ser units (#440) * add furySerTest * add kryInOutPutTest * add MsgSerTest * add native hessian ser test * rename vari * final * final2 --- .../serialize/avro/AvroObjectInputOutputTest.java | 2 +- .../serialize/fury/FurySerializationTest.java | 67 +++++++++++++++ .../serialize/kryo/KryObjectInputOutputTest.java} | 81 +++++++++--------- .../msgpack/MsgpackSerializationTest.java | 64 +++++++++++++++ .../NativeHessianObjectInputOutputTest.java} | 81 +++++++++--------- .../org/apache/dubbo/serialize/hessian/Person.java | 96 ++++++++++++++++++++++ .../support/GenericProtobufSerialization.java | 5 +- 7 files changed, 312 insertions(+), 84 deletions(-) diff --git a/dubbo-serialization-extensions/dubbo-serialization-avro/src/test/java/org/apache/dubbo/common/serialize/avro/AvroObjectInputOutputTest.java b/dubbo-serialization-extensions/dubbo-serialization-avro/src/test/java/org/apache/dubbo/common/serialize/avro/AvroObjectInputOutputTest.java index 0ef1f3a9..5ede1fcd 100644 --- a/dubbo-serialization-extensions/dubbo-serialization-avro/src/test/java/org/apache/dubbo/common/serialize/avro/AvroObjectInputOutputTest.java +++ b/dubbo-serialization-extensions/dubbo-serialization-avro/src/test/java/org/apache/dubbo/common/serialize/avro/AvroObjectInputOutputTest.java @@ -186,7 +186,7 @@ public class AvroObjectInputOutputTest { avroObjectOutput.flushBuffer(); pos.close(); - //这里会丢失所有信息 + //All the information is lost here Object result = avroObjectInput.readObject(); assertThat(result, not(nullValue())); diff --git a/dubbo-serialization-extensions/dubbo-serialization-fury/src/test/java/org/apache/dubbo/common/serialize/fury/FurySerializationTest.java b/dubbo-serialization-extensions/dubbo-serialization-fury/src/test/java/org/apache/dubbo/common/serialize/fury/FurySerializationTest.java new file mode 100644 index 00000000..2fe91102 --- /dev/null +++ b/dubbo-serialization-extensions/dubbo-serialization-fury/src/test/java/org/apache/dubbo/common/serialize/fury/FurySerializationTest.java @@ -0,0 +1,67 @@ +/* + * 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.dubbo.common.serialize.fury; + +import org.apache.dubbo.common.serialize.ObjectInput; +import org.apache.dubbo.common.serialize.ObjectOutput; +import org.apache.dubbo.common.serialize.fury.dubbo.FuryObjectInput; +import org.apache.dubbo.common.serialize.fury.dubbo.FuryObjectOutput; +import org.apache.dubbo.common.serialize.fury.dubbo.FurySerialization; + +import org.hamcrest.Matchers; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +import static org.apache.dubbo.common.serialize.fury.dubbo.FurySerialization.FURY_SERIALIZATION_ID; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.mockito.Mockito.mock; + +public class FurySerializationTest { + private FurySerialization FurySerialization; + + @BeforeEach + public void setUp() { + this.FurySerialization = new FurySerialization(); + } + + @Test + public void testContentType() { + assertThat(FurySerialization.getContentType(), is("fury/consistent")); + } + + @Test + public void testContentTypeId() { + assertThat(FurySerialization.getContentTypeId(), is(FURY_SERIALIZATION_ID)); + } + + @Test + public void testObjectOutput() throws IOException { + ObjectOutput objectOutput = FurySerialization.serialize(null, mock(OutputStream.class)); + assertThat(objectOutput, Matchers.<ObjectOutput>instanceOf(FuryObjectOutput.class)); + } + + @Test + public void testObjectInput() throws IOException { + ObjectInput objectInput = FurySerialization.deserialize(null, mock(InputStream.class)); + assertThat(objectInput, Matchers.<ObjectInput>instanceOf(FuryObjectInput.class)); + } +} diff --git a/dubbo-serialization-extensions/dubbo-serialization-avro/src/test/java/org/apache/dubbo/common/serialize/avro/AvroObjectInputOutputTest.java b/dubbo-serialization-extensions/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/serialize/kryo/KryObjectInputOutputTest.java similarity index 66% copy from dubbo-serialization-extensions/dubbo-serialization-avro/src/test/java/org/apache/dubbo/common/serialize/avro/AvroObjectInputOutputTest.java copy to dubbo-serialization-extensions/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/serialize/kryo/KryObjectInputOutputTest.java index 0ef1f3a9..c11b52b8 100644 --- a/dubbo-serialization-extensions/dubbo-serialization-avro/src/test/java/org/apache/dubbo/common/serialize/avro/AvroObjectInputOutputTest.java +++ b/dubbo-serialization-extensions/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/serialize/kryo/KryObjectInputOutputTest.java @@ -14,10 +14,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.common.serialize.avro; +package org.apache.dubbo.common.serialize.kryo; import org.apache.dubbo.common.serialize.model.Person; + import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -32,9 +33,9 @@ import static org.hamcrest.core.IsNot.not; import static org.hamcrest.core.IsNull.nullValue; -public class AvroObjectInputOutputTest { - private AvroObjectInput avroObjectInput; - private AvroObjectOutput avroObjectOutput; +public class KryObjectInputOutputTest { + private KryoObjectInput kryoObjectInput; + private KryoObjectOutput kryoObjectOutput; private PipedOutputStream pos; private PipedInputStream pis; @@ -45,8 +46,8 @@ public class AvroObjectInputOutputTest { pos = new PipedOutputStream(); pis.connect(pos); - avroObjectOutput = new AvroObjectOutput(pos); - avroObjectInput = new AvroObjectInput(pis); + kryoObjectOutput = new KryoObjectOutput(pos); + kryoObjectInput = new KryoObjectInput(pis); } @AfterEach @@ -63,98 +64,98 @@ public class AvroObjectInputOutputTest { @Test public void testWriteReadBool() throws IOException, InterruptedException { - avroObjectOutput.writeBool(true); - avroObjectOutput.flushBuffer(); + kryoObjectOutput.writeBool(true); + kryoObjectOutput.flushBuffer(); pos.close(); - boolean result = avroObjectInput.readBool(); + boolean result = kryoObjectInput.readBool(); assertThat(result, is(true)); } @Test public void testWriteReadByte() throws IOException { - avroObjectOutput.writeByte((byte) 'a'); - avroObjectOutput.flushBuffer(); + kryoObjectOutput.writeByte((byte) 'a'); + kryoObjectOutput.flushBuffer(); pos.close(); - Byte result = avroObjectInput.readByte(); + Byte result = kryoObjectInput.readByte(); assertThat(result, is((byte) 'a')); } @Test public void testWriteReadBytes() throws IOException { - avroObjectOutput.writeBytes("123456".getBytes()); - avroObjectOutput.flushBuffer(); + kryoObjectOutput.writeBytes("123456".getBytes()); + kryoObjectOutput.flushBuffer(); pos.close(); - byte[] result = avroObjectInput.readBytes(); + byte[] result = kryoObjectInput.readBytes(); assertThat(result, is("123456".getBytes())); } @Test public void testWriteReadShort() throws IOException { - avroObjectOutput.writeShort((short) 1); - avroObjectOutput.flushBuffer(); + kryoObjectOutput.writeShort((short) 1); + kryoObjectOutput.flushBuffer(); pos.close(); - short result = avroObjectInput.readShort(); + short result = kryoObjectInput.readShort(); assertThat(result, is((short) 1)); } @Test public void testWriteReadInt() throws IOException { - avroObjectOutput.writeInt(1); - avroObjectOutput.flushBuffer(); + kryoObjectOutput.writeInt(1); + kryoObjectOutput.flushBuffer(); pos.close(); - Integer result = avroObjectInput.readInt(); + Integer result = kryoObjectInput.readInt(); assertThat(result, is(1)); } @Test public void testReadDouble() throws IOException { - avroObjectOutput.writeDouble(3.14d); - avroObjectOutput.flushBuffer(); + kryoObjectOutput.writeDouble(3.14d); + kryoObjectOutput.flushBuffer(); pos.close(); - Double result = avroObjectInput.readDouble(); + Double result = kryoObjectInput.readDouble(); assertThat(result, is(3.14d)); } @Test public void testReadLong() throws IOException { - avroObjectOutput.writeLong(10L); - avroObjectOutput.flushBuffer(); + kryoObjectOutput.writeLong(10L); + kryoObjectOutput.flushBuffer(); pos.close(); - Long result = avroObjectInput.readLong(); + Long result = kryoObjectInput.readLong(); assertThat(result, is(10L)); } @Test public void testWriteReadFloat() throws IOException { - avroObjectOutput.writeFloat(1.66f); - avroObjectOutput.flushBuffer(); + kryoObjectOutput.writeFloat(1.66f); + kryoObjectOutput.flushBuffer(); pos.close(); - Float result = avroObjectInput.readFloat(); + Float result = kryoObjectInput.readFloat(); assertThat(result, is(1.66F)); } @Test public void testWriteReadUTF() throws IOException { - avroObjectOutput.writeUTF("wording"); - avroObjectOutput.flushBuffer(); + kryoObjectOutput.writeUTF("wording"); + kryoObjectOutput.flushBuffer(); pos.close(); - String result = avroObjectInput.readUTF(); + String result = kryoObjectInput.readUTF(); assertThat(result, is("wording")); } @@ -165,11 +166,11 @@ public class AvroObjectInputOutputTest { p.setAge(30); p.setName("abc"); - avroObjectOutput.writeObject(p); - avroObjectOutput.flushBuffer(); + kryoObjectOutput.writeObject(p); + kryoObjectOutput.flushBuffer(); pos.close(); - Person result = avroObjectInput.readObject(Person.class); + Person result = kryoObjectInput.readObject(Person.class); assertThat(result, not(nullValue())); assertThat(result.getName(), is("abc")); @@ -182,12 +183,12 @@ public class AvroObjectInputOutputTest { p.setAge(30); p.setName("abc"); - avroObjectOutput.writeObject(p); - avroObjectOutput.flushBuffer(); + kryoObjectOutput.writeObject(p); + kryoObjectOutput.flushBuffer(); pos.close(); - //这里会丢失所有信息 - Object result = avroObjectInput.readObject(); + //All the information is lost here + Object result = kryoObjectInput.readObject(); assertThat(result, not(nullValue())); // assertThat(result.getName(), is("abc")); diff --git a/dubbo-serialization-extensions/dubbo-serialization-msgpack/src/test/java/org/apache/dubbo/common/serialize/msgpack/MsgpackSerializationTest.java b/dubbo-serialization-extensions/dubbo-serialization-msgpack/src/test/java/org/apache/dubbo/common/serialize/msgpack/MsgpackSerializationTest.java new file mode 100644 index 00000000..e081c2cb --- /dev/null +++ b/dubbo-serialization-extensions/dubbo-serialization-msgpack/src/test/java/org/apache/dubbo/common/serialize/msgpack/MsgpackSerializationTest.java @@ -0,0 +1,64 @@ +/* + * 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.dubbo.common.serialize.msgpack; + +import org.apache.dubbo.common.serialize.ObjectInput; +import org.apache.dubbo.common.serialize.ObjectOutput; + +import org.hamcrest.Matchers; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.mockito.Mockito.mock; + +public class MsgpackSerializationTest { + private MsgpackSerialization msgpackSerialization; + + @BeforeEach + public void setUp() { + this.msgpackSerialization = new MsgpackSerialization(); + } + + @Test + public void testContentType() { + assertThat(msgpackSerialization.getContentType(), is("text/json")); + } + + @Test + public void testContentTypeId() { + byte result = 27; + assertThat(msgpackSerialization.getContentTypeId(), is(result)); + } + + @Test + public void testObjectOutput() throws IOException { + ObjectOutput objectOutput = msgpackSerialization.serialize(null, mock(OutputStream.class)); + assertThat(objectOutput, Matchers.<ObjectOutput>instanceOf(MsgpackObjectOutput.class)); + } + + @Test + public void testObjectInput() throws IOException { + ObjectInput objectInput = msgpackSerialization.deserialize(null, mock(InputStream.class)); + assertThat(objectInput, Matchers.<ObjectInput>instanceOf(MsgpackObjectInput.class)); + } +} diff --git a/dubbo-serialization-extensions/dubbo-serialization-avro/src/test/java/org/apache/dubbo/common/serialize/avro/AvroObjectInputOutputTest.java b/dubbo-serialization-extensions/dubbo-serialization-native-hessian/src/test/java/org/apache/dubbo/serialize/hessian/NativeHessianObjectInputOutputTest.java similarity index 64% copy from dubbo-serialization-extensions/dubbo-serialization-avro/src/test/java/org/apache/dubbo/common/serialize/avro/AvroObjectInputOutputTest.java copy to dubbo-serialization-extensions/dubbo-serialization-native-hessian/src/test/java/org/apache/dubbo/serialize/hessian/NativeHessianObjectInputOutputTest.java index 0ef1f3a9..a76b16fd 100644 --- a/dubbo-serialization-extensions/dubbo-serialization-avro/src/test/java/org/apache/dubbo/common/serialize/avro/AvroObjectInputOutputTest.java +++ b/dubbo-serialization-extensions/dubbo-serialization-native-hessian/src/test/java/org/apache/dubbo/serialize/hessian/NativeHessianObjectInputOutputTest.java @@ -14,10 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.common.serialize.avro; +package org.apache.dubbo.serialize.hessian; -import org.apache.dubbo.common.serialize.model.Person; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -32,9 +31,9 @@ import static org.hamcrest.core.IsNot.not; import static org.hamcrest.core.IsNull.nullValue; -public class AvroObjectInputOutputTest { - private AvroObjectInput avroObjectInput; - private AvroObjectOutput avroObjectOutput; +public class NativeHessianObjectInputOutputTest { + private Hessian2ObjectInput hessian2ObjectInput; + private Hessian2ObjectOutput hessian2ObjectOutput; private PipedOutputStream pos; private PipedInputStream pis; @@ -45,8 +44,8 @@ public class AvroObjectInputOutputTest { pos = new PipedOutputStream(); pis.connect(pos); - avroObjectOutput = new AvroObjectOutput(pos); - avroObjectInput = new AvroObjectInput(pis); + hessian2ObjectOutput = new Hessian2ObjectOutput(pos); + hessian2ObjectInput = new Hessian2ObjectInput(pis); } @AfterEach @@ -63,98 +62,98 @@ public class AvroObjectInputOutputTest { @Test public void testWriteReadBool() throws IOException, InterruptedException { - avroObjectOutput.writeBool(true); - avroObjectOutput.flushBuffer(); + hessian2ObjectOutput.writeBool(true); + hessian2ObjectOutput.flushBuffer(); pos.close(); - boolean result = avroObjectInput.readBool(); + boolean result = hessian2ObjectInput.readBool(); assertThat(result, is(true)); } @Test public void testWriteReadByte() throws IOException { - avroObjectOutput.writeByte((byte) 'a'); - avroObjectOutput.flushBuffer(); + hessian2ObjectOutput.writeByte((byte) 'a'); + hessian2ObjectOutput.flushBuffer(); pos.close(); - Byte result = avroObjectInput.readByte(); + Byte result = hessian2ObjectInput.readByte(); assertThat(result, is((byte) 'a')); } @Test public void testWriteReadBytes() throws IOException { - avroObjectOutput.writeBytes("123456".getBytes()); - avroObjectOutput.flushBuffer(); + hessian2ObjectOutput.writeBytes("123456".getBytes()); + hessian2ObjectOutput.flushBuffer(); pos.close(); - byte[] result = avroObjectInput.readBytes(); + byte[] result = hessian2ObjectInput.readBytes(); assertThat(result, is("123456".getBytes())); } @Test public void testWriteReadShort() throws IOException { - avroObjectOutput.writeShort((short) 1); - avroObjectOutput.flushBuffer(); + hessian2ObjectOutput.writeShort((short) 1); + hessian2ObjectOutput.flushBuffer(); pos.close(); - short result = avroObjectInput.readShort(); + short result = hessian2ObjectInput.readShort(); assertThat(result, is((short) 1)); } @Test public void testWriteReadInt() throws IOException { - avroObjectOutput.writeInt(1); - avroObjectOutput.flushBuffer(); + hessian2ObjectOutput.writeInt(1); + hessian2ObjectOutput.flushBuffer(); pos.close(); - Integer result = avroObjectInput.readInt(); + Integer result = hessian2ObjectInput.readInt(); assertThat(result, is(1)); } @Test public void testReadDouble() throws IOException { - avroObjectOutput.writeDouble(3.14d); - avroObjectOutput.flushBuffer(); + hessian2ObjectOutput.writeDouble(3.14d); + hessian2ObjectOutput.flushBuffer(); pos.close(); - Double result = avroObjectInput.readDouble(); + Double result = hessian2ObjectInput.readDouble(); assertThat(result, is(3.14d)); } @Test public void testReadLong() throws IOException { - avroObjectOutput.writeLong(10L); - avroObjectOutput.flushBuffer(); + hessian2ObjectOutput.writeLong(10L); + hessian2ObjectOutput.flushBuffer(); pos.close(); - Long result = avroObjectInput.readLong(); + Long result = hessian2ObjectInput.readLong(); assertThat(result, is(10L)); } @Test public void testWriteReadFloat() throws IOException { - avroObjectOutput.writeFloat(1.66f); - avroObjectOutput.flushBuffer(); + hessian2ObjectOutput.writeFloat(1.66f); + hessian2ObjectOutput.flushBuffer(); pos.close(); - Float result = avroObjectInput.readFloat(); + Float result = hessian2ObjectInput.readFloat(); assertThat(result, is(1.66F)); } @Test public void testWriteReadUTF() throws IOException { - avroObjectOutput.writeUTF("wording"); - avroObjectOutput.flushBuffer(); + hessian2ObjectOutput.writeUTF("wording"); + hessian2ObjectOutput.flushBuffer(); pos.close(); - String result = avroObjectInput.readUTF(); + String result = hessian2ObjectInput.readUTF(); assertThat(result, is("wording")); } @@ -165,11 +164,11 @@ public class AvroObjectInputOutputTest { p.setAge(30); p.setName("abc"); - avroObjectOutput.writeObject(p); - avroObjectOutput.flushBuffer(); + hessian2ObjectOutput.writeObject(p); + hessian2ObjectOutput.flushBuffer(); pos.close(); - Person result = avroObjectInput.readObject(Person.class); + Person result = hessian2ObjectInput.readObject(Person.class); assertThat(result, not(nullValue())); assertThat(result.getName(), is("abc")); @@ -182,12 +181,12 @@ public class AvroObjectInputOutputTest { p.setAge(30); p.setName("abc"); - avroObjectOutput.writeObject(p); - avroObjectOutput.flushBuffer(); + hessian2ObjectOutput.writeObject(p); + hessian2ObjectOutput.flushBuffer(); pos.close(); - //这里会丢失所有信息 - Object result = avroObjectInput.readObject(); + //All the information is lost here + Object result = hessian2ObjectInput.readObject(); assertThat(result, not(nullValue())); // assertThat(result.getName(), is("abc")); diff --git a/dubbo-serialization-extensions/dubbo-serialization-native-hessian/src/test/java/org/apache/dubbo/serialize/hessian/Person.java b/dubbo-serialization-extensions/dubbo-serialization-native-hessian/src/test/java/org/apache/dubbo/serialize/hessian/Person.java new file mode 100644 index 00000000..ea666452 --- /dev/null +++ b/dubbo-serialization-extensions/dubbo-serialization-native-hessian/src/test/java/org/apache/dubbo/serialize/hessian/Person.java @@ -0,0 +1,96 @@ +/* + * 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.dubbo.serialize.hessian; + +import java.io.Serializable; +import java.util.Arrays; + +public class Person implements Serializable { + byte oneByte = 123; + private String name = "name1"; + private int age = 11; + + private String[] value = {"value1", "value2"}; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public byte getOneByte() { + return oneByte; + } + + public void setOneByte(byte b) { + this.oneByte = b; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + public String[] getValue() { + return value; + } + + public void setValue(String[] value) { + this.value = value; + } + + @Override + public String toString() { + return String.format("Person name(%s) age(%d) byte(%s) [value=%s]", name, age, oneByte, Arrays.toString(value)); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + age; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + Arrays.hashCode(value); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Person other = (Person) obj; + if (age != other.age) + return false; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + if (!Arrays.equals(value, other.value)) + return false; + return true; + } +} diff --git a/dubbo-serialization-extensions/dubbo-serialization-protobuf/src/main/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufSerialization.java b/dubbo-serialization-extensions/dubbo-serialization-protobuf/src/main/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufSerialization.java index 12d2f658..53b69a0e 100644 --- a/dubbo-serialization-extensions/dubbo-serialization-protobuf/src/main/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufSerialization.java +++ b/dubbo-serialization-extensions/dubbo-serialization-protobuf/src/main/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufSerialization.java @@ -17,7 +17,6 @@ package org.apache.dubbo.common.serialize.protobuf.support; import org.apache.dubbo.common.URL; -import org.apache.dubbo.common.serialize.Constants; import org.apache.dubbo.common.serialize.ObjectInput; import org.apache.dubbo.common.serialize.ObjectOutput; import org.apache.dubbo.common.serialize.Serialization; @@ -25,6 +24,8 @@ import org.apache.dubbo.common.serialize.Serialization; import java.io.InputStream; import java.io.OutputStream; +import static org.apache.dubbo.common.serialize.Constants.PROTOBUF_SERIALIZATION_ID; + /** * <p> * Currently, the Dubbo protocol / framework data, such as attachments, event data, etc., @@ -43,7 +44,7 @@ public class GenericProtobufSerialization implements Serialization { @Override public byte getContentTypeId() { - return Constants.PROTOBUF_SERIALIZATION_ID; + return PROTOBUF_SERIALIZATION_ID; } @Override