diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/strategy/AzureBlobBlockUploadStrategy.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/strategy/AzureBlobBlockUploadStrategy.java index d7258754a2..44755551fb 100644 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/strategy/AzureBlobBlockUploadStrategy.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/strategy/AzureBlobBlockUploadStrategy.java @@ -35,6 +35,7 @@ import java.util.List; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; /** * Decomposes a blob into blocks for upload and assembly through PutBlock and PutBlockList @@ -57,7 +58,7 @@ public class AzureBlobBlockUploadStrategy implements MultipartUploadStrategy { public String execute(String container, Blob blob) { String blobName = blob.getMetadata().getName(); Payload payload = blob.getPayload(); - long length = payload.getContentMetadata().getContentLength(); + Long length = payload.getContentMetadata().getContentLength(); checkNotNull(length, "please invoke payload.getContentMetadata().setContentLength(length) prior to azure block upload"); checkArgument(length <= (MAX_NUMBER_OF_BLOCKS * MAX_BLOCK_SIZE)); @@ -81,7 +82,7 @@ public class AzureBlobBlockUploadStrategy implements MultipartUploadStrategy { blockIds.add(blockId); client.putBlock(container, blobName, blockId, block); } - assert bytesWritten == length; + checkState(bytesWritten == length, "Wrote " + bytesWritten + " bytes, but we wanted to write " + length + " bytes"); return client.putBlockList(container, blobName, blockIds); } } diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/domain/internal/BlobBlockPropertiesImpl.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/domain/internal/BlobBlockPropertiesImpl.java index 7e412f9ff5..b2d15d7933 100755 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/domain/internal/BlobBlockPropertiesImpl.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/domain/internal/BlobBlockPropertiesImpl.java @@ -19,6 +19,7 @@ package org.jclouds.azureblob.domain.internal; import org.jclouds.azureblob.domain.BlobBlockProperties; import com.google.common.base.Objects; +import static com.google.common.base.Preconditions.checkNotNull; /** * Representation of the blocks which compose a Blob @@ -29,7 +30,7 @@ public class BlobBlockPropertiesImpl implements BlobBlockProperties { private final boolean committed; public BlobBlockPropertiesImpl(String blockName, long contentLength, boolean committed) { - this.blockName = blockName; + this.blockName = checkNotNull(blockName); this.contentLength = contentLength; this.committed = committed; } diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/predicates/validators/BlockIdValidator.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/predicates/validators/BlockIdValidator.java index 9003f87c74..cd6d53f771 100644 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/predicates/validators/BlockIdValidator.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/predicates/validators/BlockIdValidator.java @@ -33,8 +33,8 @@ import org.jclouds.predicates.Validator; @Singleton public class BlockIdValidator extends Validator { @Override - public void validate(@Nullable String s) throws IllegalArgumentException { - if (s.length() > 64) + public void validate(String s) throws IllegalArgumentException { + if (s == null || s.length() > 64) throw new IllegalArgumentException("block id:" + s + "; Block Ids must be less than or equal to 64 bytes in size"); } diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/xml/BlobBlocksResultsHandler.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/xml/BlobBlocksResultsHandler.java index 4a9506508b..6a566e72f4 100755 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/xml/BlobBlocksResultsHandler.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/xml/BlobBlocksResultsHandler.java @@ -30,6 +30,7 @@ import com.google.common.collect.Lists; /** * Parses the following document: + *
  * 
  * 
  * 
@@ -39,6 +40,7 @@ import com.google.common.collect.Lists;
  * 
  * 
  * 
+ * 
*/ public class BlobBlocksResultsHandler extends ParseSax.HandlerWithResult {