From 3a183e4a9ebe1754f9c6c28e30e4af6846da7ac0 Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Fri, 18 Sep 2015 15:22:28 +0200 Subject: [PATCH] BucketInfo: add null check for rules in builder. Add test case. --- .../src/main/java/com/google/gcloud/storage/BucketInfo.java | 2 +- .../test/java/com/google/gcloud/storage/BucketInfoTest.java | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) 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");