Skip to content

Commit de53c29

Browse files
authored
[fix][broker] Fix matching of topicsPattern for topic names which contain non-ascii characters (#24543)
1 parent c358e71 commit de53c29

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/TopicResources.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ void handleNotification(Notification notification) {
116116
Matcher matcher = entry.getValue().matcher(notification.getPath());
117117
if (matcher.matches()) {
118118
TopicName topicName = TopicName.get(
119-
matcher.group(2), NamespaceName.get(matcher.group(1)), matcher.group(3));
119+
matcher.group(2), NamespaceName.get(matcher.group(1)), decode(matcher.group(3)));
120120
entry.getKey().accept(topicName.toString(), notification.getType());
121121
}
122122
}

pulsar-broker-common/src/test/java/org/apache/pulsar/broker/resources/TopicResourcesTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,13 @@ public void testListenerNotInvokedAfterDeregistered() {
114114
verifyNoMoreInteractions(listener);
115115
}
116116

117+
@Test
118+
public void testListenerInvokedWithDecodedTopicName() {
119+
BiConsumer<String, NotificationType> listener = mock(BiConsumer.class);
120+
topicResources.registerPersistentTopicListener(NamespaceName.get("tenant/namespace"), listener);
121+
topicResources.handleNotification(new Notification(NotificationType.Created,
122+
"/managed-ledgers/tenant/namespace/persistent/topic%3Atest"));
123+
verify(listener).accept("persistent://tenant/namespace/topic:test", NotificationType.Created);
124+
}
125+
117126
}

0 commit comments

Comments
 (0)