Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -714,8 +714,12 @@ private BucketInfo.LifecycleRule lifecycleRuleDecode(Bucket.Lifecycle.Rule from)
.collect(ImmutableList.toImmutableList());
conditionBuilder.setMatchesStorageClass(collect);
}
conditionBuilder.setMatchesPrefix(condition.getMatchesPrefixList());
conditionBuilder.setMatchesSuffix(condition.getMatchesSuffixList());
if (!condition.getMatchesPrefixList().isEmpty()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change looks out of context, is it needed as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a difference between what is constructed via

 LifecycleRule d1 =
        new LifecycleRule(
            LifecycleAction.newAbortIncompleteMPUploadAction(),
            LifecycleCondition.newBuilder().setAge(0).build());

And what is decoded coming back from the service via grpc. By simply setting as we were doing before the value would be empty list rather than null. Apiary on the other hand will be null by default. This change brings these both in line with the apiary behavior.

conditionBuilder.setMatchesPrefix(condition.getMatchesPrefixList());
}
if (!condition.getMatchesSuffixList().isEmpty()) {
conditionBuilder.setMatchesSuffix(condition.getMatchesSuffixList());
}
return new BucketInfo.LifecycleRule(lifecycleAction, conditionBuilder.build());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,22 @@ public void deleteRule_addingALabelToABucketWithASingleDeleteRuleOnlyModifiesThe
}
}

@Test
public void condition_ageDays_0_shouldWork() throws Exception {
LifecycleRule d1 =
new LifecycleRule(
LifecycleAction.newAbortIncompleteMPUploadAction(),
LifecycleCondition.newBuilder().setAge(0).build());
BucketInfo info = baseInfo().setLifecycleRules(ImmutableList.of(d1)).build();

try (TemporaryBucket tmp =
TemporaryBucket.newBuilder().setBucketInfo(info).setStorage(storage).build()) {
BucketInfo bucket = tmp.getBucket();
Bucket update = storage.get(bucket.getName());
assertThat(update.getLifecycleRules()).isEqualTo(ImmutableList.of(d1));
}
}

@Test
public void deleteRule_modifyingLifecycleRulesMatchesLastOperation() throws Exception {
BucketInfo info;
Expand Down