From db699a43c0a06083ebc70c0c273a590ceacba21f Mon Sep 17 00:00:00 2001 From: TomlongTK Date: Thu, 21 Mar 2024 16:26:20 +0800 Subject: [PATCH] Fix readBytes and writeBytes methods in fastjson2 (#13968) --- .../common/serialize/fastjson2/FastJson2ObjectInput.java | 2 +- .../common/serialize/fastjson2/FastJson2ObjectOutput.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dubbo-serialization/dubbo-serialization-fastjson2/src/main/java/org/apache/dubbo/common/serialize/fastjson2/FastJson2ObjectInput.java b/dubbo-serialization/dubbo-serialization-fastjson2/src/main/java/org/apache/dubbo/common/serialize/fastjson2/FastJson2ObjectInput.java index a167ea3983c3..52d486ec67d9 100644 --- a/dubbo-serialization/dubbo-serialization-fastjson2/src/main/java/org/apache/dubbo/common/serialize/fastjson2/FastJson2ObjectInput.java +++ b/dubbo-serialization/dubbo-serialization-fastjson2/src/main/java/org/apache/dubbo/common/serialize/fastjson2/FastJson2ObjectInput.java @@ -91,7 +91,7 @@ public String readUTF() throws IOException { @Override public byte[] readBytes() throws IOException { - int length = is.read(); + int length = readLength(); byte[] bytes = new byte[length]; int read = is.read(bytes, 0, length); if (read != length) { diff --git a/dubbo-serialization/dubbo-serialization-fastjson2/src/main/java/org/apache/dubbo/common/serialize/fastjson2/FastJson2ObjectOutput.java b/dubbo-serialization/dubbo-serialization-fastjson2/src/main/java/org/apache/dubbo/common/serialize/fastjson2/FastJson2ObjectOutput.java index f596b8db4a62..0240e009d722 100644 --- a/dubbo-serialization/dubbo-serialization-fastjson2/src/main/java/org/apache/dubbo/common/serialize/fastjson2/FastJson2ObjectOutput.java +++ b/dubbo-serialization/dubbo-serialization-fastjson2/src/main/java/org/apache/dubbo/common/serialize/fastjson2/FastJson2ObjectOutput.java @@ -89,13 +89,13 @@ public void writeUTF(String v) throws IOException { @Override public void writeBytes(byte[] b) throws IOException { - os.write(b.length); + writeLength(b.length); os.write(b); } @Override public void writeBytes(byte[] b, int off, int len) throws IOException { - os.write(len); + writeLength(len); os.write(b, off, len); }