-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[fix](s3) Add limit-aware brace expansion and fix misleading glob metrics #61843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -456,5 +456,46 @@ public void testExpandBracketPatterns_malformedBracket() { | |||||||||||||||||||
| // Malformed bracket (no closing ]) - [ kept as literal | ||||||||||||||||||||
| Assert.assertEquals("file[abc.csv", S3Util.expandBracketPatterns("file[abc.csv")); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // Tests for limit-aware expandBracePatterns | ||||||||||||||||||||
|
|
||||||||||||||||||||
| @Test | ||||||||||||||||||||
| public void testExpandBracePatterns_withinLimit() { | ||||||||||||||||||||
| // Expansion within the limit should succeed | ||||||||||||||||||||
| List<String> result = S3Util.expandBracePatterns("file{1,2,3}.csv", 10); | ||||||||||||||||||||
| Assert.assertEquals(Arrays.asList("file1.csv", "file2.csv", "file3.csv"), result); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| @Test | ||||||||||||||||||||
| public void testExpandBracePatterns_exactlyAtLimit() { | ||||||||||||||||||||
| // Expansion exactly at the limit should succeed | ||||||||||||||||||||
| List<String> result = S3Util.expandBracePatterns("file{1,2,3}.csv", 3); | ||||||||||||||||||||
| Assert.assertEquals(Arrays.asList("file1.csv", "file2.csv", "file3.csv"), result); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| @Test(expected = S3Util.BraceExpansionTooLargeException.class) | ||||||||||||||||||||
| public void testExpandBracePatterns_exceedsLimit() { | ||||||||||||||||||||
| // Expansion exceeding the limit should throw | ||||||||||||||||||||
| S3Util.expandBracePatterns("file{1,2,3,4,5}.csv", 3); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| @Test(expected = S3Util.BraceExpansionTooLargeException.class) | ||||||||||||||||||||
| public void testExpandBracePatterns_oneOverLimit() { | ||||||||||||||||||||
| // maxPaths+1 items must also throw (boundary case) | ||||||||||||||||||||
| S3Util.expandBracePatterns("file{1,2,3,4}.csv", 3); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| @Test(expected = S3Util.BraceExpansionTooLargeException.class) | ||||||||||||||||||||
| public void testExpandBracePatterns_cartesianExceedsLimit() { | ||||||||||||||||||||
| // Cartesian product {a,b,c} x {1,2,3} = 9 paths, limit = 5 | ||||||||||||||||||||
| S3Util.expandBracePatterns("dir{a,b,c}/file{1,2,3}.csv", 5); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| @Test | ||||||||||||||||||||
| public void testExpandBracePatterns_zeroLimitMeansUnlimited() { | ||||||||||||||||||||
| // maxPaths=0 means no limit (backward compatibility) | ||||||||||||||||||||
| List<String> result = S3Util.expandBracePatterns("file{1,2,3,4,5}.csv", 0); | ||||||||||||||||||||
| Assert.assertEquals(5, result.size()); | ||||||||||||||||||||
|
Comment on lines
+494
to
+498
|
||||||||||||||||||||
| @Test | |
| public void testExpandBracePatterns_zeroLimitMeansUnlimited() { | |
| // maxPaths=0 means no limit (backward compatibility) | |
| List<String> result = S3Util.expandBracePatterns("file{1,2,3,4,5}.csv", 0); | |
| Assert.assertEquals(5, result.size()); | |
| @Test(expected = IllegalArgumentException.class) | |
| public void testExpandBracePatterns_zeroLimitIsInvalid() { | |
| // maxPaths must be > 0; zero is an invalid argument | |
| S3Util.expandBracePatterns("file{1,2,3,4,5}.csv", 0); |
Uh oh!
There was an error while loading. Please reload this page.