-
Notifications
You must be signed in to change notification settings - Fork 910
Fix Trailer based Http Checksum for Async Request body with variable chunk size #3380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
e0c75c3
to
42a3d05
Compare
42a3d05
to
f6a7a43
Compare
ByteBuffer checksumAppendedBuffer = ByteBuffer.allocate(contentChunk.remaining()); | ||
checksumAppendedBuffer.put(contentChunk); | ||
checksumAppendedBuffer.flip(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the need for this. Why create a copy of contentChunk
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
.../amazon/awssdk/core/internal/interceptor/AsyncRequestBodyHttpChecksumTrailerInterceptor.java
Outdated
Show resolved
Hide resolved
f3ac7de
to
ac0e9cf
Compare
ac0e9cf
to
f02605b
Compare
...main/java/software/amazon/awssdk/core/internal/io/AwsUnsignedChunkedEncodingInputStream.java
Outdated
Show resolved
Hide resolved
utils/src/main/java/software/amazon/awssdk/utils/async/ByteBufferingSubscriber.java
Outdated
Show resolved
Hide resolved
9662737
to
423686c
Compare
@@ -28,12 +28,16 @@ | |||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat; | |||
import static software.amazon.awssdk.http.Header.CONTENT_LENGTH; | |||
import static software.amazon.awssdk.http.Header.CONTENT_TYPE; | |||
import static software.amazon.awssdk.testutils.FileUtils.fixedLengthInKbFileWithRandomOrFixedCharacters; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will raise another PR for converting this to Junit5 .
423686c
to
b662515
Compare
...rc/it/java/software/amazon/awssdk/services/s3/checksum/AsyncHttpChecksumIntegrationTest.java
Outdated
Show resolved
Hide resolved
@@ -41,6 +42,8 @@ | |||
@SdkInternalApi | |||
public class ChecksumCalculatingAsyncRequestBody implements AsyncRequestBody { | |||
|
|||
public static final int DEFAULT_CHUNK_SIZE = 16 * 1024; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of making it a public member in this class, can we create a constant class to put all checksum related chunk size constants?
...ain/java/software/amazon/awssdk/core/internal/async/ChecksumCalculatingAsyncRequestBody.java
Outdated
Show resolved
Hide resolved
...ain/java/software/amazon/awssdk/core/internal/async/ChecksumCalculatingAsyncRequestBody.java
Outdated
Show resolved
Hide resolved
services/s3/src/test/java/software/amazon/awssdk/services/s3/utils/ChecksumUtils.java
Outdated
Show resolved
Hide resolved
...ain/java/software/amazon/awssdk/core/internal/async/ChecksumCalculatingAsyncRequestBody.java
Outdated
Show resolved
Hide resolved
a16a18b
to
1dcd041
Compare
1dcd041
to
7eba119
Compare
|
||
public List<ByteBuffer> getBufferedList() { | ||
if (currentBuffer == null) { | ||
throw new IllegalStateException(""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currentBuffer should never be null, right?
* Class that will buffer incoming BufferBytes of totalBytes length to chunks of bufferSize* | ||
*/ | ||
@SdkInternalApi | ||
public final class ChunkBuffer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed offline, we should probably make this thread safe
Kudos, SonarCloud Quality Gate passed! |
Please retry analysis of this Pull-Request directly on SonarCloud. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we trigger the test suites if we haven't already
…55c7c4cb3 Pull request: release <- staging/94641a3e-f760-4614-bf42-f4d55c7c4cb3
Motivation and Context
Fix Trailer based Http Checksum for Async Request body created from File
Modifications
The Non last chunks in ChecksumCalculatingAsyncRequestBody.
ChecksumCalculatingSubscriber
was not appending the Chunk size and Carriage return to the chunks.The FileAsynRequest Body was not handled , this sends the data in chunks of 16KB, thus the Content-length is updated to consider additional bytes due to size and Carriage return
Added ChunkBuffer class that will Buffer the incoming bytes until it reaches
buffer_size
Added flatMapIterable to wrapped netty stream of data such that we map it to ChunkBuffer
wrapped.flatMapIterable(this::buffer).subscribe(new ChecksumCalculatingSubscriber(s, sdkChecksum, trailerHeader, totalBytes));
Testing
Screenshots (if appropriate)
Types of changes
License