From faf6b2f39ef82417ec89b20bbda51287643d401d Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Wed, 27 Feb 2013 11:28:11 -0800 Subject: [PATCH] Prohibit null and empty blob names in BlobBuilder --- .../blobstore/domain/internal/BlobBuilderImpl.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/BlobBuilderImpl.java b/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/BlobBuilderImpl.java index a74f7f1a91..0f3e45dcb5 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/BlobBuilderImpl.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/BlobBuilderImpl.java @@ -18,7 +18,9 @@ */ package org.jclouds.blobstore.domain.internal; +import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; import static org.jclouds.io.Payloads.newPayload; import java.io.File; @@ -48,6 +50,8 @@ public class BlobBuilderImpl implements BlobBuilder { @Override public BlobBuilder name(String name) { + checkNotNull(name, "name"); + checkArgument(!name.isEmpty(), "name"); this.name = name; return this; } @@ -106,8 +110,8 @@ public class BlobBuilderImpl implements BlobBuilder { @Override public Blob build() { Blob blob = new BlobImpl(new MutableBlobMetadataImpl()); - if (name != null) - blob.getMetadata().setName(name); + checkState(name != null, "name"); + blob.getMetadata().setName(name); if (payload != null) blob.setPayload(payload); blob.getMetadata().setUserMetadata(userMetadata);