Skip to content

Commit

Permalink
Fix bug: unnecessary read of data content - corrupt output
Browse files Browse the repository at this point in the history
  • Loading branch information
psolomin committed Apr 28, 2023
1 parent 1049e12 commit 06510b6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public CopyOutCommand(
this.resultHandler = resultHandler;
this.collector = Collector.of(
Buffer::buffer,
// TODO: this might be unnecessary slow - think of alternatives
(v, chunk) -> v.appendBuffer(Buffer.buffer(chunk)),
(v1, v2) -> null,
(finalResult) -> finalResult
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public int size() {
return size;
}

public void handleChunk(int len, ByteBuf in) {
public void handleChunk(ByteBuf in) {
if (failure != null) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,7 @@ private void decodeCopyOutResponse(ChannelHandlerContext ctx, ByteBuf in) {}
private void decodeCopyData(ChannelHandlerContext ctx, ByteBuf in) {
PgCommandCodec<?, ?> codec = inflight.peek();
CopyOutCommandCodec cmdCodec = (CopyOutCommandCodec) codec;
int len = in.readUnsignedShort();
cmdCodec.decoder.handleChunk(len, in);
cmdCodec.decoder.handleChunk(in);
}

private void decodeCopyCompletion(ChannelHandlerContext ctx, ByteBuf in) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ public void testCopyToCsvBytes(TestContext ctx) {
ctx.assertEquals(10, result.size());
ctx.assertEquals(
Buffer.buffer(
"Whatever-0\n" +
"Whatever-1\n" +
"Whatever-2\n" +
"Whatever-3\n" +
"Whatever-4\n" +
"Whatever-5\n" +
"Whatever-6\n" +
"Whatever-7\n" +
"Whatever-8\n" +
"Whatever-9\n"
"0,Whatever-0\n" +
"1,Whatever-1\n" +
"2,Whatever-2\n" +
"3,Whatever-3\n" +
"4,Whatever-4\n" +
"5,Whatever-5\n" +
"6,Whatever-6\n" +
"7,Whatever-7\n" +
"8,Whatever-8\n" +
"9,Whatever-9\n"
),
result.value()
);
Expand Down

0 comments on commit 06510b6

Please sign in to comment.