File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed
main/java/com/google/cloud/storage
test/java/com/google/cloud/storage/it Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -714,8 +714,12 @@ private BucketInfo.LifecycleRule lifecycleRuleDecode(Bucket.Lifecycle.Rule from)
714714 .collect (ImmutableList .toImmutableList ());
715715 conditionBuilder .setMatchesStorageClass (collect );
716716 }
717- conditionBuilder .setMatchesPrefix (condition .getMatchesPrefixList ());
718- conditionBuilder .setMatchesSuffix (condition .getMatchesSuffixList ());
717+ if (!condition .getMatchesPrefixList ().isEmpty ()) {
718+ conditionBuilder .setMatchesPrefix (condition .getMatchesPrefixList ());
719+ }
720+ if (!condition .getMatchesSuffixList ().isEmpty ()) {
721+ conditionBuilder .setMatchesSuffix (condition .getMatchesSuffixList ());
722+ }
719723 return new BucketInfo .LifecycleRule (lifecycleAction , conditionBuilder .build ());
720724 }
721725
Original file line number Diff line number Diff line change @@ -72,6 +72,22 @@ public void deleteRule_addingALabelToABucketWithASingleDeleteRuleOnlyModifiesThe
7272 }
7373 }
7474
75+ @ Test
76+ public void condition_ageDays_0_shouldWork () throws Exception {
77+ LifecycleRule d1 =
78+ new LifecycleRule (
79+ LifecycleAction .newAbortIncompleteMPUploadAction (),
80+ LifecycleCondition .newBuilder ().setAge (0 ).build ());
81+ BucketInfo info = baseInfo ().setLifecycleRules (ImmutableList .of (d1 )).build ();
82+
83+ try (TemporaryBucket tmp =
84+ TemporaryBucket .newBuilder ().setBucketInfo (info ).setStorage (storage ).build ()) {
85+ BucketInfo bucket = tmp .getBucket ();
86+ Bucket update = storage .get (bucket .getName ());
87+ assertThat (update .getLifecycleRules ()).isEqualTo (ImmutableList .of (d1 ));
88+ }
89+ }
90+
7591 @ Test
7692 public void deleteRule_modifyingLifecycleRulesMatchesLastOperation () throws Exception {
7793 BucketInfo info ;
You can’t perform that action at this time.
0 commit comments