Skip to content

Commit 8e30f41

Browse files
committed
Added logic in MakeHttpRequestStage to check and abort request if interrupted
1 parent 7b6c66e commit 8e30f41

File tree

4 files changed

+224
-284
lines changed

4 files changed

+224
-284
lines changed

core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/http/pipeline/stages/MakeHttpRequestStage.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,11 @@ private HttpExecuteResponse executeHttpRequest(SdkHttpFullRequest request, Reque
7575
context.apiCallAttemptTimeoutTracker().abortable(requestCallable);
7676

7777
Pair<HttpExecuteResponse, Duration> measuredExecute = MetricUtils.measureDurationUnsafe(requestCallable);
78-
7978
attemptMetricCollector.reportMetric(CoreMetric.SERVICE_CALL_DURATION, measuredExecute.right());
80-
79+
if (Thread.currentThread().isInterrupted()) {
80+
requestCallable.abort();
81+
InterruptMonitor.checkInterrupted();
82+
}
8183
return measuredExecute.left();
8284
}
8385

http-clients/apache-client/src/main/java/software/amazon/awssdk/http/apache/ApacheHttpClient.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import static software.amazon.awssdk.utils.NumericUtils.saturatedCast;
2525

2626
import java.io.IOException;
27-
import java.io.InterruptedIOException;
2827
import java.net.InetAddress;
2928
import java.security.KeyManagementException;
3029
import java.security.NoSuchAlgorithmException;
@@ -230,10 +229,6 @@ public ExecutableHttpRequest prepareRequest(HttpExecuteRequest request) {
230229
@Override
231230
public HttpExecuteResponse call() throws IOException {
232231
HttpExecuteResponse executeResponse = execute(apacheRequest, metricCollector);
233-
if (Thread.interrupted()) {
234-
abort();
235-
throw new InterruptedIOException(Thread.currentThread().getName() + " was interrupted");
236-
}
237232
collectPoolMetric(metricCollector);
238233
return executeResponse;
239234
}

http-clients/apache-client/src/test/java/software/amazon/awssdk/http/apache/ApacheHttpClientThreadInterruptTest.java

Lines changed: 0 additions & 277 deletions
This file was deleted.

0 commit comments

Comments
 (0)