File tree 2 files changed +22
-2
lines changed
main/java/com/google/cloud/storage
test/java/com/google/cloud/storage/it 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)
714
714
.collect (ImmutableList .toImmutableList ());
715
715
conditionBuilder .setMatchesStorageClass (collect );
716
716
}
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
+ }
719
723
return new BucketInfo .LifecycleRule (lifecycleAction , conditionBuilder .build ());
720
724
}
721
725
Original file line number Diff line number Diff line change @@ -72,6 +72,22 @@ public void deleteRule_addingALabelToABucketWithASingleDeleteRuleOnlyModifiesThe
72
72
}
73
73
}
74
74
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
+
75
91
@ Test
76
92
public void deleteRule_modifyingLifecycleRulesMatchesLastOperation () throws Exception {
77
93
BucketInfo info ;
You can’t perform that action at this time.
0 commit comments