Source:
public UpdateResponse updateBlobMetadata(BlobId blobId, Map<String, Object> updateFields) throws BlobStorageException { Objects.requireNonNull(blobId, "BlobId cannot be null"); updateFields.keySet().stream().forEach(field -> Objects.requireNonNull(updateFields.get(field))); try { BlockBlobClient blobClient = getBlockBlobClient(blobId, false); Timer.Context storageTimer = azureMetrics.blobUpdateTime.time(); try { BlobProperties blobProperties = blobClient.getPropertiesWithResponse(defaultRequestConditions, requestTimeout, Context.NONE).getValue(); String etag = blobProperties.getETag(); Map<String, String> metadata = blobProperties.getMetadata(); Map<String, String> changedFields = updateFields.entrySet() .stream() .filter(entry -> !String.valueOf(entry.getValue()).equals(metadata.get(entry.getKey()))) .collect(Collectors.toMap(entry -> entry.getKey(), entry -> String.valueOf(entry.getValue()))); if (changedFields.size() > 0) { changedFields.forEach((key, value) -> metadata.put(key, value)); if (updateCallback != null) { try { updateCallback.call(); } catch (Exception ex) { logger.error("Error in update callback", ex); } } BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setIfMatch(etag); blobClient.setMetadataWithResponse(metadata, blobRequestConditions, requestTimeout, Context.NONE); return new UpdateResponse(true, metadata); } else { return new UpdateResponse(false, metadata); } } finally { storageTimer.stop(); } } catch (BlobStorageException e) { if (isNotFoundError(e.getErrorCode())) { logger.warn("Blob not found, cannot update {}.", blobId, updateFields.keySet()); } if (e.getErrorCode() == BlobErrorCode.CONDITION_NOT_MET) { azureMetrics.blobUpdateConflictCount.inc(); } throw e; } }

Target:
public UpdateResponse updateBlobMetadata(BlobId blobId, Map<String, Object> updateFields) throws BlobStorageException { Objects.requireNonNull(blobId, "BlobId cannot be null"); updateFields.keySet() .forEach(field -> Objects.requireNonNull(updateFields.get(field), String.format("%s cannot be null", field))); try { BlockBlobClient blobClient = getBlockBlobClient(blobId, false); Timer.Context storageTimer = azureMetrics.blobUpdateTime.time(); try { BlobProperties blobProperties = blobClient.getPropertiesWithResponse(defaultRequestConditions, requestTimeout, Context.NONE).getValue(); String etag = blobProperties.getETag(); Map<String, String> metadata = blobProperties.getMetadata(); Map<String, String> changedFields = updateFields.entrySet() .stream() .filter(entry -> !String.valueOf(entry.getValue()).equals(metadata.get(entry.getKey()))) .collect(Collectors.toMap(Map.Entry::getKey, entry -> String.valueOf(entry.getValue()))); if (changedFields.size() > 0) { changedFields.forEach(metadata::put); if (updateCallback != null) { try { updateCallback.call(); } catch (Exception ex) { logger.error("Error in update callback", ex); } } BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setIfMatch(etag); blobClient.setMetadataWithResponse(metadata, blobRequestConditions, requestTimeout, Context.NONE); return new UpdateResponse(true, metadata); } else { return new UpdateResponse(false, metadata); } } finally { storageTimer.stop(); } } catch (BlobStorageException e) { if (isNotFoundError(e.getErrorCode())) { logger.warn("Blob not found, cannot update {}.", blobId, updateFields.keySet()); } if (e.getErrorCode() == BlobErrorCode.CONDITION_NOT_MET) { azureMetrics.blobUpdateConflictCount.inc(); } throw e; } }