Skip to content

Commit 0ce2e41

Browse files
zoewanggCopilot
andauthored
Apply suggestions from code review
Co-authored-by: Copilot <[email protected]>
1 parent e5708e1 commit 0ce2e41

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/async/BufferingAsyncRequestBody.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,9 @@ private void doProcessRequest() {
284284
int currentIndex = this.index.getAndIncrement();
285285

286286
if (currentIndex >= buffers.size()) {
287-
// This should never happen, but defensive programming
287+
// This should never happen because shouldProcessRequest() ensures that index.get() < buffers.size()
288+
// before incrementing. If this condition is true, it likely indicates a concurrency bug or that buffers
289+
// was modified unexpectedly. This defensive check is here to catch such rare, unexpected situations.
288290
notifyError(new IllegalStateException("Index out of bounds"));
289291
subscriptions.remove(this);
290292
return;

core/sdk-core/src/test/java/software/amazon/awssdk/core/internal/async/BufferingAsyncRequestBodyTckTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public Publisher<ByteBuffer> createPublisher(long elements) {
4242
public Publisher<ByteBuffer> createFailedPublisher() {
4343
BufferingAsyncRequestBody bufferingAsyncRequestBody = new BufferingAsyncRequestBody(1024L);
4444
bufferingAsyncRequestBody.close();
45-
return null;
45+
return bufferingAsyncRequestBody;
4646
}
4747

4848
public long maxElementsFromPublisher() {

core/sdk-core/src/test/java/software/amazon/awssdk/core/internal/async/BufferingAsyncRequestBodyTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ private static void verifyData(Subscriber<ByteBuffer> subscriber) {
156156
argThat(buffer -> Arrays.equals(BinaryUtils.copyBytesFrom(buffer), TEST_DATA_SET_1.array())));
157157
verify(subscriber).onNext(
158158
argThat(buffer -> Arrays.equals(BinaryUtils.copyBytesFrom(buffer), TEST_DATA_SET_2.array())));
159-
verify(subscriber).onComplete();
160159
}
161160

162161
@Test

0 commit comments

Comments
 (0)