Skip to content

Commit 8ceb610

Browse files
oneby-wangganesh-ctds
authored andcommitted
[fix][client] Fix invalid parameter type passed to Map.get in TopicsImpl.getListAsync method (apache#25069)
(cherry picked from commit f9bb2e4) (cherry picked from commit 85bccb4)
1 parent 6b27381 commit 8ceb610

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApi2Test.java

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
import org.apache.pulsar.broker.testcontext.PulsarTestContext;
9292
import org.apache.pulsar.client.admin.GrantTopicPermissionOptions;
9393
import org.apache.pulsar.client.admin.ListNamespaceTopicsOptions;
94+
import org.apache.pulsar.client.admin.ListTopicsOptions;
9495
import org.apache.pulsar.client.admin.Mode;
9596
import org.apache.pulsar.client.admin.PulsarAdmin;
9697
import org.apache.pulsar.client.admin.PulsarAdminException;
@@ -1058,9 +1059,29 @@ public void testPersistentTopicList() throws Exception {
10581059
}
10591060
}
10601061

1061-
Set<String> topicsInNs = Sets
1062-
.newHashSet(
1063-
admin.topics().getList(namespace, null, Collections.singletonMap(QueryParam.Bundle, bundle)));
1062+
Set<String> topicsInNs;
1063+
// 1. test recommended sync method
1064+
ListTopicsOptions listTopicsOptions = ListTopicsOptions.builder().bundle(bundle).build();
1065+
topicsInNs = Sets.newHashSet(admin.topics().getList(namespace, null, listTopicsOptions));
1066+
assertEquals(topicsInNs.size(), topics.size());
1067+
topicsInNs.removeAll(topics);
1068+
assertEquals(topicsInNs.size(), 0);
1069+
1070+
// 2. test recommended async method
1071+
topicsInNs = Sets.newHashSet(admin.topics().getListAsync(namespace, null, listTopicsOptions).get());
1072+
assertEquals(topicsInNs.size(), topics.size());
1073+
topicsInNs.removeAll(topics);
1074+
assertEquals(topicsInNs.size(), 0);
1075+
1076+
// 3. test deprecated sync method
1077+
Map<QueryParam, Object> queryOption = Collections.singletonMap(QueryParam.Bundle, bundle);
1078+
topicsInNs = Sets.newHashSet(admin.topics().getList(namespace, null, queryOption));
1079+
assertEquals(topicsInNs.size(), topics.size());
1080+
topicsInNs.removeAll(topics);
1081+
assertEquals(topicsInNs.size(), 0);
1082+
1083+
// 4. test deprecated async method
1084+
topicsInNs = Sets.newHashSet(admin.topics().getListAsync(namespace, null, queryOption).get());
10641085
assertEquals(topicsInNs.size(), topics.size());
10651086
topicsInNs.removeAll(topics);
10661087
assertEquals(topicsInNs.size(), 0);

pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/TopicsImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public CompletableFuture<List<String>> getListAsync(String namespace, TopicDomai
184184
Map<QueryParam, Object> params) {
185185
ListTopicsOptions options = ListTopicsOptions
186186
.builder()
187-
.bundle((String) params.get(QueryParam.Bundle.value))
187+
.bundle((String) params.get(QueryParam.Bundle))
188188
.build();
189189
return getListAsync(namespace, topicDomain, options);
190190
}

0 commit comments

Comments
 (0)