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
1 parent 717db5e commit fe6356c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}
Expand Down

0 comments on commit fe6356c

Please sign in to comment.