This is an automated email from the ASF dual-hosted git repository.

lhotari pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit 0a21e64e6b2320b03b306d6b265521b4e06e007e
Author: Lari Hotari <[email protected]>
AuthorDate: Tue Jul 22 19:56:11 2025 +0300

    [fix][broker] Fix matching of topicsPattern for topic names which contain 
non-ascii characters (#24543)
    
    (cherry picked from commit de53c29528e6c8caca7c432098a1b7eec074ae45)
---
 .../java/org/apache/pulsar/broker/resources/TopicResources.java  | 2 +-
 .../org/apache/pulsar/broker/resources/TopicResourcesTest.java   | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git 
a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/TopicResources.java
 
b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/TopicResources.java
index f607da76b3c..8ce4e5c8e20 100644
--- 
a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/TopicResources.java
+++ 
b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/TopicResources.java
@@ -116,7 +116,7 @@ public class TopicResources {
                 Matcher matcher = 
entry.getValue().matcher(notification.getPath());
                 if (matcher.matches()) {
                     TopicName topicName = TopicName.get(
-                            matcher.group(2), 
NamespaceName.get(matcher.group(1)), matcher.group(3));
+                            matcher.group(2), 
NamespaceName.get(matcher.group(1)), decode(matcher.group(3)));
                     entry.getKey().accept(topicName.toString(), 
notification.getType());
                 }
             }
diff --git 
a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/resources/TopicResourcesTest.java
 
b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/resources/TopicResourcesTest.java
index 6db6b145cc7..07a4ae195c8 100644
--- 
a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/resources/TopicResourcesTest.java
+++ 
b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/resources/TopicResourcesTest.java
@@ -114,4 +114,13 @@ public class TopicResourcesTest {
         verifyNoMoreInteractions(listener);
     }
 
+    @Test
+    public void testListenerInvokedWithDecodedTopicName() {
+        BiConsumer<String, NotificationType> listener = mock(BiConsumer.class);
+        
topicResources.registerPersistentTopicListener(NamespaceName.get("tenant/namespace"),
 listener);
+        topicResources.handleNotification(new 
Notification(NotificationType.Created,
+                "/managed-ledgers/tenant/namespace/persistent/topic%3Atest"));
+        verify(listener).accept("persistent://tenant/namespace/topic:test", 
NotificationType.Created);
+    }
+
 }

Reply via email to