Created
December 2, 2020 15:06
-
-
Save jkeillor/9b41a4b36ba0ff1613421ccf5c0f0566 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/http/async/AsyncResponseHandler.java b/core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/http/async/AsyncResponseHandler.java | |
index 81400eaefc..7f0c5ddb96 100644 | |
--- a/core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/http/async/AsyncResponseHandler.java | |
+++ b/core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/http/async/AsyncResponseHandler.java | |
@@ -80,10 +80,13 @@ public final class AsyncResponseHandler<T> implements TransformingAsyncResponseH | |
public CompletableFuture<T> prepare() { | |
streamFuture = new CompletableFuture<>(); | |
return streamFuture.thenCompose(baos -> { | |
- ByteArrayInputStream content = new ByteArrayInputStream(baos.toByteArray()); | |
- // Ignore aborts - we already have all of the content. | |
- AbortableInputStream abortableContent = AbortableInputStream.create(content); | |
- httpResponse.content(abortableContent); | |
+ byte[] output = baos.toByteArray(); | |
+ if(output.length > 0) { | |
+ ByteArrayInputStream content = new ByteArrayInputStream(baos.toByteArray()); | |
+ // Ignore aborts - we already have all of the content. | |
+ AbortableInputStream abortableContent = AbortableInputStream.create(content); | |
+ httpResponse.content(abortableContent); | |
+ } | |
try { | |
return CompletableFuture.completedFuture(responseHandler.handle(crc32Validator.apply(httpResponse.build()), | |
executionAttributes)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment