Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Commit 14589f6

Browse files
committed
🐛 fix issue #88 error trying to create a iterator for a empty path
1 parent 1e79b15 commit 14589f6

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/main/java/com/upplication/s3fs/S3Path.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,10 @@ public Iterator<Path> iterator() {
528528
}
529529

530530
List<String> paths = uriToList();
531+
532+
if (uriToList().isEmpty())
533+
return builder.build().iterator();
534+
531535
String lastPath = paths.get(paths.size() - 1);
532536

533537
for (String path : uriToList()) {

src/test/java/com/upplication/s3fs/Path/ItearatorTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import static com.upplication.s3fs.util.S3EndpointConstant.S3_GLOBAL_URI_TEST;
1616
import static org.junit.Assert.assertEquals;
17+
import static org.junit.Assert.assertFalse;
1718

1819
public class ItearatorTest extends S3UnitTestBase {
1920

@@ -39,5 +40,11 @@ public void iterator() {
3940
assertEquals(getPath("file"), iterator.next());
4041
}
4142

43+
@Test
44+
public void iteratorEmtpy() {
45+
Iterator<Path> iterator = getPath("").iterator();
46+
assertFalse(iterator.hasNext());
47+
}
48+
4249

4350
}

0 commit comments

Comments
 (0)