Skip to content

Commit d87d8fb

Browse files
committed
added PooledMemoryStream disposal on oneshot upload
1 parent d41080c commit d87d8fb

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

sdk/storage/Azure.Storage.Common/src/Shared/PartitionedUploader.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,8 @@ public async Task<Response<TCompleteUploadReturn>> UploadInternal(
380380
// If we know the length and it's small enough
381381
if (length < _singleUploadThreshold)
382382
{
383+
IDisposable disposable = null;
384+
383385
// may not be seekable. buffer if that's the case
384386
if (!content.CanSeek)
385387
{
@@ -394,10 +396,11 @@ public async Task<Response<TCompleteUploadReturn>> UploadInternal(
394396
maxArrayPoolRentalSize: default,
395397
async,
396398
cancellationToken).ConfigureAwait(false);
399+
disposable = content;
397400
}
398401

399402
// Upload it in a single request
400-
return await _singleUploadStreamingInternal(
403+
var result = await _singleUploadStreamingInternal(
401404
content,
402405
args,
403406
progressHandler,
@@ -406,6 +409,9 @@ public async Task<Response<TCompleteUploadReturn>> UploadInternal(
406409
async,
407410
cancellationToken)
408411
.ConfigureAwait(false);
412+
413+
disposable?.Dispose();
414+
return result;
409415
}
410416

411417
// If the caller provided an explicit block size, we'll use it.

0 commit comments

Comments
 (0)