diff --git a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/codec/ByteArrayInputStreamCodec.java b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/codec/ByteArrayInputStreamCodec.java index 3af23a3bc..c31261f5a 100644 --- a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/codec/ByteArrayInputStreamCodec.java +++ b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/codec/ByteArrayInputStreamCodec.java @@ -86,16 +86,13 @@ public Mono publishBinary(ByteBufAllocator allocator) { try { VarIntUtils.writeVarInt(buf, size); - - byte[] byteArray = new byte[size]; - int readBytes = value.read(byteArray); - + int readBytes = buf.writeBytes(value, size); if (readBytes != size) { buf.release(); throw new IllegalStateException("Expected to read " + size + " bytes, but got " + readBytes); } - return buf.writeBytes(byteArray); + return buf; } catch (Exception e) { buf.release(); throw new RuntimeException(e);