@@ -111,6 +111,7 @@ private S3MetaRequestWrapper s3MetaRequest() {
111
111
112
112
@ Override
113
113
public void onResponseHeaders (int statusCode , HttpHeader [] headers ) {
114
+ log .debug (() -> "Received response header with status code " + statusCode );
114
115
// Note, we cannot call responseHandler.onHeaders() here because the response status code and headers may not represent
115
116
// whether the request has succeeded or not (e.g. if this is for a HeadObject call that CRT calls under the hood). We
116
117
// need to rely on onResponseBody/onFinished being called to determine this.
@@ -150,6 +151,7 @@ public int onResponseBody(ByteBuffer bodyBytesIn, long objectRangeStart, long ob
150
151
@ Override
151
152
public void onFinished (S3FinishedResponseContext context ) {
152
153
int crtCode = context .getErrorCode ();
154
+ log .debug (() -> "Request finished with code: " + crtCode );
153
155
if (crtCode != CRT .AWS_CRT_SUCCESS ) {
154
156
handleError (context );
155
157
} else {
@@ -192,6 +194,19 @@ private void handleIoError(S3FinishedResponseContext context, int crtCode) {
192
194
SdkClientException .create ("Failed to send the request: " +
193
195
CRT .awsErrorString (crtCode ), cause );
194
196
failResponseHandlerAndFuture (sdkClientException );
197
+ notifyResponsePublisherErrorIfNeeded (sdkClientException );
198
+ }
199
+
200
+ private void notifyResponsePublisherErrorIfNeeded (Throwable error ) {
201
+ if (responseHandlingInitiated ) {
202
+ responsePublisher .error (error ).handle ((ignore , throwable ) -> {
203
+ if (throwable != null ) {
204
+ log .error (() -> "Exception thrown in responsePublisher#error" , throwable );
205
+ return null ;
206
+ }
207
+ return null ;
208
+ });
209
+ }
195
210
}
196
211
197
212
private void handleServiceError (int responseStatus , HttpHeader [] headers , byte [] errorPayload ) {
@@ -204,6 +219,7 @@ private void handleServiceError(int responseStatus, HttpHeader[] headers, byte[]
204
219
SdkClientException .create ("Request failed during the transfer due to an error returned from S3" );
205
220
s3Exception .addSuppressed (sdkClientException );
206
221
failResponseHandlerAndFuture (s3Exception );
222
+ notifyResponsePublisherErrorIfNeeded (s3Exception );
207
223
} else {
208
224
initiateResponseHandling (errorResponse .build ());
209
225
onErrorResponseComplete (errorPayload );
0 commit comments