diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BucketInfo.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BucketInfo.java index 437ce1a142d5..28110e0a0292 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BucketInfo.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BucketInfo.java @@ -453,7 +453,7 @@ public Builder notFoundPage(String notFoundPage) { } public Builder deleteRules(Iterable rules) { - this.deleteRules = ImmutableList.copyOf(rules); + this.deleteRules = rules != null ? ImmutableList.copyOf(rules) : null; return this; } diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BucketInfoTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BucketInfoTest.java index 27a5b4014f3f..c4f08fbd8b9b 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BucketInfoTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BucketInfoTest.java @@ -90,6 +90,12 @@ public void testToBuilder() { compareBuckets(BUCKET_INFO, bucketInfo); } + @Test + public void testToBuilderIncomplete() { + BucketInfo incompleteBucketInfo = BucketInfo.builder("b").build(); + assertEquals(incompleteBucketInfo.name(), incompleteBucketInfo.toBuilder().build().name()); + } + @Test public void testOf() { BucketInfo bucketInfo = BucketInfo.of("bucket");