aws / aws/amazon-s3-encryption-client-java

S3EncryptionClient (not async) Unable to execute HTTP request: headersFuture is still not completed when onStream() is invoked.

未关闭
#186 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
bug question
主要语言
Java
星标
34
派生
21
PR 合并指标
30 天内没有已合并 PR

描述

The code where I create S3EncryptionClient and call it (3.1.1 library version)

```
private S3EncryptionClient getEncryptionClient(String regionName, KeyPair keyPair) {
return S3EncryptionClient.builder()
.rsaKeyPair(keyPair)
.enableDelayedAuthenticationMode(true)
.enableLegacyUnauthenticatedModes(true)
.enableLegacyWrappingAlgorithms(true)
.wrappedClient(getClient(regionName))
.wrappedAsyncClient(getAsyncClient(regionName))
.build();
}
...
private S3AsyncClient getAsyncClient(String regionName) {
return S3AsyncClient.builder()
.overrideConfiguration(createClientConfiguration())
.region(Region.of(regionName))
.build();
}
..
private ClientOverrideConfiguration createClientConfiguration() {
return S3Client.builder()
.httpClient(
ApacheHttpClient.builder()
.connectionTimeout(Duration.ofMillis(clientConnectionTimeout))
.build())
.overrideConfiguration()
.toBuilder()
.retryPolicy(RetryPolicy.builder().numRetries(NUM_RETRIES).build())
.apiCallAttemptTimeout(Duration.ofMillis(clientRequestTimeout))
.build();
}
...
...
return getInputStream(s3Client.getObject(getGetObjectRequest(storageKey)), isZip);
...
private InputStream getInputStream(ResponseInputStream is, boolean isZip)
throws IOException {
InputStream s3InputStream;
if (isZip) {
ZipInputStream zis = new ZipInputStream(is);
ZipEntry zipEntry = zis.getNextEntry(); // There should be only one entry in the ZIP file

log.debug("getReader: Found zip entry {}", zipEntry.getName());

s3InputStream = zis;
} else {
s3InputStream = is;
}
return s3InputStream;
}
```
The error I see:

```
Caused by: sotware.amazon.encryption.s3.S3EncryptionClientException: Unable to execute HTTP request: headersFuture is still not completed when onStream() is invoked.
at deployment.fs.war//software.amazon.encryption.s3.S3EncryptionClient.getObject(S3EncryptionClient.java:255)

Caused by: software.amazon.awssdk.core.exception.SdkClientException: Unable to execute HTTP request: headersFuture is still not completed when onStream() is invoked.
at deployment.fs.war//software.amazon.awssdk.core.exception.SdkClientException$BuilderImpl.build(SdkClientException.java:111)
at deployment.fs.war//software.amazon.awssdk.core.exception.SdkClientException.create(SdkClientException.java:47)
at deployment.fs.war//software.amazon.awssdk.core.internal.http.pipeline.stages.utils.RetryableStageHelper.setLastException(RetryableStageHelper.java:223)
at deployment.fs.war//software.amazon.awssdk.core.internal.http.pipeline.stages.utils.RetryableStageHelper.setLastException(RetryableStageHelper.java:218)
at deployment.fs.war//software.amazon.awssdk.core.internal.http.pipeline.stages.AsyncRetryableStage$RetryingExecutor.maybeRetryExecute(AsyncRetryableStage.java:182)
at deployment.fs.war//software.amazon.awssdk.core.internal.http.pipeline.stages.AsyncRetryableStage$RetryingExecutor.lambda$attemptExecute$1(AsyncRetryableStage.java:159)
at java.base/java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:859)
at java.base/java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:837)
at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506)
at java.base/java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:2088)
at deployment.fs.war//software.amazon.awssdk.utils.CompletableFutureUtils.lambda$forwardExceptionTo$0(CompletableFutureUtils.java:79)
at java.base/java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:859)
at java.base/java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:837)
at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506)
at java.base/java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:2088)
at deployment.fs.war//software.amazon.awssdk.core.internal.http.pipeline.stages.MakeAsyncHttpRequestStage.lambda$execute$0(MakeAsyncHttpRequestStage.java:108)
at java.base/java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:859)
at java.base/java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:837)
at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506)
at java.base/java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:2088)
at deployment.fs.war//software.amazon.awssdk.core.internal.http.pipeline.stages.MakeAsyncHttpRequestStage.completeResponseFuture(MakeAsyncHttpRequestStage.java:255)
at deployment.fs.war//software.amazon.awssdk.core.internal.http.pipeline.stages.MakeAsyncHttpRequestStage.lambda$executeHttpRequest$3(MakeAsyncHttpRequestStage.java:167)
at java.base/java.util.concurrent.CompletableFuture.uniHandle(CompletableFuture.java:930)
at java.base/java.util.concurrent.CompletableFuture$UniHandle.tryFire(CompletableFuture.java:907)
at java.base/java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:478)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
```

The question is - why do I see something about the future if I do not use an async client?
How can I correctly get the response and use InputStream here? I can't see any wait/join function to wait

贡献指南

打开贡献指南

调研方向

从 stack trace 第 255 行标识的 S3EncryptionClient.getObject 入手,并比较报告中显示的封装后的 S3Client 和 S3AsyncClient 配置。使用提供的客户端设置复现请求,并确定同步调用为何会到达 headersFuture 错误;当确定了受支持的 response/InputStream 用法或确认了客户端缺陷时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
aws, java
领域
api, backend
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。