Skip to content

Commit ed84cca

Browse files
authored
Storage - [Content Validation] Make synchronous stageBlock request body replayable on retry (#49612)
* Make synchronous stageBlock request body replayable on retry * updating assets (unrelated to the changes in this PR) * updating recordings
1 parent 71762ab commit ed84cca

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

sdk/storage/azure-storage-blob/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "java",
44
"TagPrefix": "java/storage/azure-storage-blob",
5-
"Tag": "java/storage/azure-storage-blob_afc0d343f3"
5+
"Tag": "java/storage/azure-storage-blob_494b72fca7"
66
}

sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlockBlobClient.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,17 @@
3838
import com.azure.storage.blob.options.BlockBlobSimpleUploadOptions;
3939
import com.azure.storage.blob.options.BlockBlobStageBlockFromUrlOptions;
4040
import com.azure.storage.blob.options.BlockBlobStageBlockOptions;
41+
import com.azure.storage.common.Utility;
4142
import com.azure.storage.common.implementation.Constants;
4243
import com.azure.storage.common.implementation.StorageImplUtils;
4344
import com.azure.storage.common.implementation.StorageSeekableByteChannel;
45+
import reactor.core.publisher.Flux;
4446
import reactor.core.publisher.Mono;
4547

4648
import java.io.InputStream;
4749
import java.io.UncheckedIOException;
4850
import java.net.URL;
51+
import java.nio.ByteBuffer;
4952
import java.nio.channels.SeekableByteChannel;
5053
import java.time.Duration;
5154
import java.util.List;
@@ -783,10 +786,13 @@ public Response<Void> stageBlockWithResponse(String base64BlockId, InputStream d
783786
String leaseId, Duration timeout, Context context) {
784787
StorageImplUtils.assertNotNull("data", data);
785788

786-
Mono<Response<Void>> response = client.stageBlockWithResponseInternal(
787-
new BlockBlobStageBlockOptions(base64BlockId, BinaryData.fromStream(data, length)).setContentMd5(contentMd5)
788-
.setLeaseId(leaseId),
789-
context);
789+
Flux<ByteBuffer> fbb
790+
= Utility.convertStreamToByteBuffer(data, length, BlobAsyncClient.BLOB_DEFAULT_UPLOAD_BLOCK_SIZE, true);
791+
792+
Mono<Response<Void>> response = BinaryData.fromFlux(fbb, length, false)
793+
.flatMap(binaryData -> client.stageBlockWithResponseInternal(
794+
new BlockBlobStageBlockOptions(base64BlockId, binaryData).setContentMd5(contentMd5).setLeaseId(leaseId),
795+
context));
790796
return blockWithOptionalTimeout(response, timeout);
791797
}
792798

0 commit comments

Comments
 (0)