Source:
public void upload(File file, String objectId, String md5, boolean redo) throws IOException { val spec = storageService.initiateUpload(objectId, file.length(), redo, md5); Pair<Integer, Long> partInfo = this.calculateNumBlocks(file.length(), BLOCK_SIZE); if (spec.getParts().isEmpty()) { throw new NotRetryableException(new Exception("Did not get an Upload Part definition from service")); } URI sasUrl; try { sasUrl = new URI(spec.getParts().get(0).getUrl()); } catch (URISyntaxException e) { throw new NotRetryableException(e); } try { val blob = new CloudBlockBlob(sasUrl); val progress = new Progress(terminal, false, Math.toIntExact(partInfo.getLeft()), 0); OperationContext ctx = new OperationContext(); AtomicInteger completedParts = new AtomicInteger(); ctx.getResponseReceivedEventHandler().addListener(new StorageEvent<ResponseReceivedEvent>() { @Override public void eventOccurred(ResponseReceivedEvent eventArg) { long bytesSent = BLOCK_SIZE; int partCount = completedParts.incrementAndGet(); if (partCount <= partInfo.getLeft()) { progress.incrementParts(1); progress.incrementBytesWritten(partCount == partInfo.getLeft() ? bytesSent = partInfo.getRight() : bytesSent); } } }); ctx.getRetryingEventHandler().addListener(new StorageEvent<RetryingEvent>() { @Override public void eventOccurred(RetryingEvent eventArg) { log.info("Upload required a retry - just saying"); } }); BlobRequestOptions options = new BlobRequestOptions(); options.setConcurrentRequestCount(parallelUploads); progress.start(); progress.startTransfer(); blob.uploadFromFile(file.getAbsolutePath(), new AccessCondition(), options, ctx); progress.stop(); progress.end(false); } catch (StorageException e) { throw new NotRetryableException(e); } }

Target:
public void upload(File file, String objectId, String md5, boolean redo) throws IOException { val spec = storageService.initiateUpload(objectId, file.length(), redo, md5); val partInfo = calculateNumBlocks(file.length(), BLOCK_SIZE); if (spec.getParts().isEmpty()) { throw new NotRetryableException(new Exception( "Did not get a valid ObjectSpecification from service: missing Part definition.")); } val sasUrl = extractSAS(spec); try { val blob = new CloudBlockBlob(sasUrl); val progress = new Progress(terminal, false, Math.toIntExact(partInfo.getLeft()), 0); val ctx = new OperationContext(); val completedParts = new AtomicInteger(); ctx.getResponseReceivedEventHandler().addListener(new StorageEvent<ResponseReceivedEvent>() { @Override public void eventOccurred(ResponseReceivedEvent eventArg) { long bytesSent = BLOCK_SIZE; int partCount = completedParts.incrementAndGet(); if (partCount <= partInfo.getLeft()) { progress.incrementParts(1); progress.incrementBytesWritten(partCount == partInfo.getLeft() ? bytesSent = partInfo.getRight() : bytesSent); } } }); ctx.getResponseReceivedEventHandler().addListener(new StorageEvent<ResponseReceivedEvent>() { @Override public void eventOccurred(ResponseReceivedEvent eventArg) { long bytesSent = BLOCK_SIZE; int partCount = completedParts.incrementAndGet(); if (partCount <= partInfo.getLeft()) { progress.incrementParts(1); progress.incrementBytesWritten(partCount == partInfo.getLeft() ? bytesSent = partInfo.getRight() : bytesSent); } } }); ctx.getRetryingEventHandler().addListener(new StorageEvent<RetryingEvent>() { @Override public void eventOccurred(RetryingEvent eventArg) { log.info("Upload required a retry - just saying"); } }); val options = new BlobRequestOptions(); options.setConcurrentRequestCount(parallelUploads); progress.start(); progress.startTransfer(); blob.uploadFromFile(file.getAbsolutePath(), new AccessCondition(), options, ctx); progress.stop(); progress.end(false); } catch (StorageException e) { throw new NotRetryableException(e); } }