Skip to content

Commit 4639d41

Browse files
authored
Update window using correct remaining() value (#4184)
This commit fixes an issue where the receive window for the CRT client is updated with the value of remaining() *after* it's been read, which is incorrect as this will be 0 if the buffer has been fully consumed, which is it should be.
1 parent 87b36dd commit 4639d41

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

services/s3/src/main/java/software/amazon/awssdk/services/s3/internal/crt/S3CrtResponseHandlerAdapter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public int onResponseBody(ByteBuffer bodyBytesIn, long objectRangeStart, long ob
6969
return 0;
7070
}
7171

72+
int bytesReceived = bodyBytesIn.remaining();
7273
CompletableFuture<Void> writeFuture = responsePublisher.send(bodyBytesIn);
7374

7475
writeFuture.whenComplete((result, failure) -> {
@@ -77,7 +78,7 @@ public int onResponseBody(ByteBuffer bodyBytesIn, long objectRangeStart, long ob
7778
return;
7879
}
7980

80-
metaRequest.incrementReadWindow(bodyBytesIn.remaining());
81+
metaRequest.incrementReadWindow(bytesReceived);
8182
});
8283

8384
// Returning 0 to disable flow control because we manually increase read window above

0 commit comments

Comments
 (0)