Skip to content

Commit

Permalink
S3: cancel the meta request before release the native handler (#764)
Browse files Browse the repository at this point in the history
  • Loading branch information
TingDaoK authored Feb 25, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 717db5e commit fe6356c
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -38,6 +38,13 @@ protected boolean canReleaseReferencesImmediately() {
@Override
protected void releaseNativeHandle() {
if (!isNull()) {
/**
* Cancel the meta request before drop the refcount.
* The meta request is not referenced by Java any longer, everything from native to Java will be ignored.
* Cancelling the meta request instead of letting it keep flowing.
* Note: If the meta request has not finished yet, it will be finished with `AWS_ERROR_S3_CANCELED`.
**/
s3MetaRequestCancel(getNativeHandle());
s3MetaRequestDestroy(getNativeHandle());
}
}
Original file line number Diff line number Diff line change
@@ -67,8 +67,10 @@ public void onFinished(S3FinishedResponseContext context) {
.withMetaRequestType(MetaRequestType.DEFAULT).withHttpRequest(httpRequest)
.withResponseHandler(responseHandler).withSigningConfig(config);

try (S3MetaRequest metaRequest = client.makeMetaRequest(metaRequestOptions)) {
}
S3MetaRequest metaRequest = client.makeMetaRequest(metaRequestOptions);
future.whenComplete((r,t) -> {
metaRequest.close();
});
return future;

}

0 comments on commit fe6356c

Please sign in to comment.