Skip to content

Commit 30b15c3

Browse files
zhuxiaolong37huiguangjun
authored andcommitted
lifecycle interface cancels the rule number limit
1 parent 63fcc9b commit 30b15c3

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

src/main/java/com/aliyun/oss/model/SetBucketLifecycleRequest.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ public void setLifecycleRules(List<LifecycleRule> lifecycleRules) {
4444
throw new IllegalArgumentException("lifecycleRules should not be null or empty.");
4545
}
4646

47-
if (lifecycleRules.size() > MAX_LIFECYCLE_RULE_LIMIT) {
48-
throw new IllegalArgumentException("One bucket not allow exceed one thousand items of LifecycleRules.");
49-
}
50-
5147
this.lifecycleRules.clear();
5248
this.lifecycleRules.addAll(lifecycleRules);
5349
}
@@ -61,10 +57,6 @@ public void AddLifecycleRule(LifecycleRule lifecycleRule) {
6157
throw new IllegalArgumentException("lifecycleRule should not be null or empty.");
6258
}
6359

64-
if (this.lifecycleRules.size() >= MAX_LIFECYCLE_RULE_LIMIT) {
65-
throw new IllegalArgumentException("One bucket not allow exceed one thousand items of LifecycleRules.");
66-
}
67-
6860
if (lifecycleRule.getId() != null && lifecycleRule.getId().length() > MAX_RULE_ID_LENGTH) {
6961
throw new IllegalArgumentException("Length of lifecycle rule id exceeds max limit " + MAX_RULE_ID_LENGTH);
7062
}

src/test/java/com/aliyun/oss/integrationtests/BucketLifecycleTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,4 +898,23 @@ public void testNormalSetBucketLifecycleWithNot() throws ParseException {
898898
ossClient.deleteBucket(bucketName);
899899
}
900900
}
901+
902+
@Test
903+
public void testVerificationLifecycleRulesLimit() throws ParseException {
904+
final String matchPrefix0 = "prefix/";
905+
final int maxLimit = 2000;
906+
907+
try {
908+
SetBucketLifecycleRequest request = new SetBucketLifecycleRequest(bucketName);
909+
for (int i = 0; i < (maxLimit + 1) ; i++) {
910+
LifecycleRule rule = new LifecycleRule("ruleId"+i, matchPrefix0+i, RuleStatus.Enabled);
911+
rule.setCreatedBeforeDate(DateUtil.parseIso8601Date("2023-10-12T00:00:00.000Z"));
912+
request.AddLifecycleRule(rule);
913+
}
914+
915+
Assert.assertTrue(true);
916+
} catch (Exception e) {
917+
Assert.fail(e.getMessage());
918+
}
919+
}
901920
}

0 commit comments

Comments
 (0)