Skip to content

Handling interrupted exception when calling CRT for signing #2705

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

Merged
merged 4 commits into from
Sep 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ public SdkHttpFullRequest signRequest(SdkHttpFullRequest request, AwsSigningConf
try {
HttpRequest signedRequest = future.get();
return requestConverter.crtRequestToHttp(request, signedRequest);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw SdkClientException.create("The thread got interrupted while attempting to sign request: " + e.getMessage(), e);
} catch (Exception e) {
throw SdkClientException.builder()
.message("Unable to sign request: " + e.getMessage())
.cause(e)
.build();
throw SdkClientException.create("Unable to sign request: " + e.getMessage(), e);
}
}

Expand All @@ -57,11 +57,11 @@ public SdkSigningResult sign(SdkHttpFullRequest request, AwsSigningConfig signin
try {
AwsSigningResult signingResult = future.get();
return requestConverter.crtResultToAws(request, signingResult);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw SdkClientException.create("The thread got interrupted while attempting to sign request: " + e.getMessage(), e);
} catch (Exception e) {
throw SdkClientException.builder()
.message("Unable to sign request: " + e.getMessage())
.cause(e)
.build();
throw SdkClientException.create("Unable to sign request: " + e.getMessage(), e);
}
}

Expand All @@ -70,11 +70,11 @@ public byte[] signChunk(byte[] chunkBody, byte[] previousSignature, AwsSigningCo
CompletableFuture<byte[]> future = AwsSigner.signChunk(crtBody, previousSignature, signingConfig);
try {
return future.get();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw SdkClientException.create("The thread got interrupted while attempting to sign request: " + e.getMessage(), e);
} catch (Exception e) {
throw SdkClientException.builder()
.message("Unable to sign chunk: " + e.getMessage())
.cause(e)
.build();
throw SdkClientException.create("Unable to sign request: " + e.getMessage(), e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,12 @@ public SdkHttpRequest modifyHttpRequest(Context.ModifyHttpRequest context,
ConfiguredS3SdkHttpRequest configuredRequest = S3EndpointResolverFactory.getEndpointResolver(resolverFactoryContext)
.applyEndpointConfiguration(resolverContext);

configuredRequest.signingRegionModification()
.map(region -> executionAttributes.putAttribute(AwsSignerExecutionAttribute.SIGNING_REGION, region))
.orElseGet(() -> executionAttributes.putAttribute(AwsSignerExecutionAttribute.SIGNING_REGION_SCOPE,
RegionScope.GLOBAL));
if (configuredRequest.signingRegionModification().isPresent()) {
executionAttributes.putAttribute(AwsSignerExecutionAttribute.SIGNING_REGION,
configuredRequest.signingRegionModification().get());
} else {
executionAttributes.putAttribute(AwsSignerExecutionAttribute.SIGNING_REGION_SCOPE, RegionScope.GLOBAL);
}

configuredRequest.signingServiceModification().ifPresent(
name -> executionAttributes.putAttribute(AwsSignerExecutionAttribute.SERVICE_SIGNING_NAME, name));
Expand Down