fix: azure close download body in CopyObject to prevent resource leak

When copying between two different Azure blobs, the source download
stream body was only consumed by PutObject but never explicitly closed.
If PutObject or any subsequent step returned an error, the underlying
HTTP connection held by the Azure SDK was never released, leaking both
the connection and any internal SDK retry goroutines attached to it.
Added a deferred close on downloadResp.Body immediately after the
successful DownloadStream call to ensure the body is always drained and
released regardless of the outcome.
This commit is contained in:
Ben McClelland
2026-03-03 08:58:31 -08:00
parent dc31696e53
commit 271313b036
+1
View File
@@ -1042,6 +1042,7 @@ func (az *Azure) CopyObject(ctx context.Context, input s3response.CopyObjectInpu
if err != nil {
return s3response.CopyObjectOutput{}, azureErrToS3Err(err)
}
defer downloadResp.Body.Close()
pInput := s3response.PutObjectInput{
Body: downloadResp.Body,