We are uploading data to Azure Blob Storage using Microsoft's Java client library. First we create a blob for uploading:
CloudBlobContainer container = client.getContainerReference(containerName);
CloudBlockBlob blob = container.getBlockBlobReference(nativePath);
Each part to be uploaded is done with code like this:
try (InputStream inputStream = new FileInputStream(part.path.toFile())) {
String blockId = String.format("%05d", part.index);
String blockIdEncoded = DatatypeConverter.printBase64Binary(blockId.getBytes());
blob.uploadBlock(blockIdEncoded, inputStream, part.size);
}
at the end, all of the parts are stitched together into a blob using:
blob.commitBlockList(blockList);
What happens if this process is abandoned (due to termination or logic error) before the commitBlockList() is called? Do the parts leak? Are they garbage collected eventually? Can I see them somewhere on the Azure portal?
How should I terminate this process gracefully so that all of the uploaded-but-unused parts are deleted?