Fix readBytes and writeBytes methods in fastjson2 (#13968)
This commit is contained in:
parent
afcf04d6e3
commit
164aebf6ed
|
|
@ -91,7 +91,7 @@ public class FastJson2ObjectInput implements ObjectInput {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] readBytes() throws IOException {
|
public byte[] readBytes() throws IOException {
|
||||||
int length = is.read();
|
int length = readLength();
|
||||||
byte[] bytes = new byte[length];
|
byte[] bytes = new byte[length];
|
||||||
int read = is.read(bytes, 0, length);
|
int read = is.read(bytes, 0, length);
|
||||||
if (read != length) {
|
if (read != length) {
|
||||||
|
|
|
||||||
|
|
@ -89,13 +89,13 @@ public class FastJson2ObjectOutput implements ObjectOutput {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeBytes(byte[] b) throws IOException {
|
public void writeBytes(byte[] b) throws IOException {
|
||||||
os.write(b.length);
|
writeLength(b.length);
|
||||||
os.write(b);
|
os.write(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeBytes(byte[] b, int off, int len) throws IOException {
|
public void writeBytes(byte[] b, int off, int len) throws IOException {
|
||||||
os.write(len);
|
writeLength(len);
|
||||||
os.write(b, off, len);
|
os.write(b, off, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue