Skip to content

Commit 1772123

Browse files
committed
Fix FilePart position when using zero-copy, close AsyncHttpClient#1123
1 parent 97e7ce9 commit 1772123

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

client/src/main/java/org/asynchttpclient/request/body/multipart/part/FileMultipartPart.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ protected long transferContentTo(ByteBuf target) throws IOException {
5959

6060
@Override
6161
protected long transferContentTo(WritableByteChannel target) throws IOException {
62-
long transferred = channel.transferTo(channel.position(), BodyChunkedInput.DEFAULT_CHUNK_SIZE, target);
62+
// WARN: don't use channel.position(), it's always 0 here
63+
// from FileChannel javadoc: "This method does not modify this channel's position."
64+
long transferred = channel.transferTo(position, BodyChunkedInput.DEFAULT_CHUNK_SIZE, target);
6365
position += transferred;
6466
if (position == length) {
6567
state = MultipartState.POST_CONTENT;

0 commit comments

Comments
 (0)