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

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

Offen
#186 5 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
bug question
Vorherrschende Sprache
Java
Sterne
34
Forks
21
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginnen Sie bei S3EncryptionClient.getObject, das in Zeile 255 des Stacktraces identifiziert wurde, und vergleichen Sie die im Bericht gezeigte Konfiguration des umschlossenen S3Client und S3AsyncClient. Reproduzieren Sie die Anfrage mit dem bereitgestellten Client-Setup und ermitteln Sie, warum der synchrone Aufruf den headersFuture-Fehler erreicht; die Aufgabe ist abgeschlossen, wenn die unterstützte response/InputStream-Nutzung oder ein bestätigter Client-Fehler festgestellt wurde.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
aws, java
Bereich
api, backend
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.