Skip to content

Commit e656065

Browse files
authored
[fix]Fixed getChildren('/') on Oxia based provider (#24863)
1 parent c9b734b commit e656065

File tree

2 files changed

+6
-18
lines changed

2 files changed

+6
-18
lines changed

pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/oxia/OxiaMetadataStore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ Stat convertStat(String path, Version version) {
149149

150150
@Override
151151
public CompletableFuture<List<String>> getChildrenFromStore(String path) {
152-
var pathWithSlash = path + "/";
152+
var pathWithSlash = path.endsWith("/") ? path : path + "/";
153153

154154
return client
155155
.list(pathWithSlash, pathWithSlash + "/")

pulsar-metadata/src/test/java/org/apache/pulsar/metadata/MetadataStoreTest.java

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -667,27 +667,15 @@ public void testGetChildren(String provider, Supplier<String> urlSupplier) throw
667667
store.put("/a/a-2", "value1".getBytes(StandardCharsets.UTF_8), Optional.empty()).join();
668668
store.put("/b/c/b/1", "value1".getBytes(StandardCharsets.UTF_8), Optional.empty()).join();
669669

670-
List<String> subPaths = store.getChildren("/").get();
671-
Set<String> ignoredRootPaths = Set.of("zookeeper");
672-
Set<String> expectedSet = Set.of("a", "b");
673-
for (String subPath : subPaths) {
674-
if (ignoredRootPaths.contains(subPath)) {
675-
continue;
676-
}
677-
assertThat(expectedSet).contains(subPath);
678-
}
670+
List<String> subPaths = new ArrayList<>(store.getChildren("/").get());
671+
subPaths.remove("zookeeper"); // ignored
672+
assertThat(subPaths).containsExactlyInAnyOrderElementsOf(Set.of("a", "b"));
679673

680674
List<String> subPaths2 = store.getChildren("/a").get();
681-
Set<String> expectedSet2 = Set.of("a-1", "a-2");
682-
for (String subPath : subPaths2) {
683-
assertThat(expectedSet2).contains(subPath);
684-
}
675+
assertThat(subPaths2).containsExactlyInAnyOrderElementsOf(Set.of("a-1", "a-2"));
685676

686677
List<String> subPaths3 = store.getChildren("/b").get();
687-
Set<String> expectedSet3 = Set.of("c");
688-
for (String subPath : subPaths3) {
689-
assertThat(expectedSet3).contains(subPath);
690-
}
678+
assertThat(subPaths3).containsExactlyInAnyOrderElementsOf(Set.of("c"));
691679
}
692680

693681
@Test(dataProvider = "impl")

0 commit comments

Comments
 (0)