Skip to content

Commit 06510b6

Browse files
committed
Fix bug: unnecessary read of data content - corrupt output
1 parent 1049e12 commit 06510b6

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/CopyOutCommand.java

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public CopyOutCommand(
2222
this.resultHandler = resultHandler;
2323
this.collector = Collector.of(
2424
Buffer::buffer,
25+
// TODO: this might be unnecessary slow - think of alternatives
2526
(v, chunk) -> v.appendBuffer(Buffer.buffer(chunk)),
2627
(v1, v2) -> null,
2728
(finalResult) -> finalResult

vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/CopyOutDataDecoder.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public int size() {
2424
return size;
2525
}
2626

27-
public void handleChunk(int len, ByteBuf in) {
27+
public void handleChunk(ByteBuf in) {
2828
if (failure != null) {
2929
return;
3030
}

vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/PgDecoder.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,7 @@ private void decodeCopyOutResponse(ChannelHandlerContext ctx, ByteBuf in) {}
475475
private void decodeCopyData(ChannelHandlerContext ctx, ByteBuf in) {
476476
PgCommandCodec<?, ?> codec = inflight.peek();
477477
CopyOutCommandCodec cmdCodec = (CopyOutCommandCodec) codec;
478-
int len = in.readUnsignedShort();
479-
cmdCodec.decoder.handleChunk(len, in);
478+
cmdCodec.decoder.handleChunk(in);
480479
}
481480

482481
private void decodeCopyCompletion(ChannelHandlerContext ctx, ByteBuf in) {}

vertx-pg-client/src/test/java/io/vertx/pgclient/PgConnectionCopyTest.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@ public void testCopyToCsvBytes(TestContext ctx) {
5050
ctx.assertEquals(10, result.size());
5151
ctx.assertEquals(
5252
Buffer.buffer(
53-
"Whatever-0\n" +
54-
"Whatever-1\n" +
55-
"Whatever-2\n" +
56-
"Whatever-3\n" +
57-
"Whatever-4\n" +
58-
"Whatever-5\n" +
59-
"Whatever-6\n" +
60-
"Whatever-7\n" +
61-
"Whatever-8\n" +
62-
"Whatever-9\n"
53+
"0,Whatever-0\n" +
54+
"1,Whatever-1\n" +
55+
"2,Whatever-2\n" +
56+
"3,Whatever-3\n" +
57+
"4,Whatever-4\n" +
58+
"5,Whatever-5\n" +
59+
"6,Whatever-6\n" +
60+
"7,Whatever-7\n" +
61+
"8,Whatever-8\n" +
62+
"9,Whatever-9\n"
6363
),
6464
result.value()
6565
);

0 commit comments

Comments
 (0)