You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by te...@apache.org on 2026/01/14 02:04:51 UTC
(pulsar) branch branch-4.1 updated: [fix][broker] Fix regex matching of namespace name which might contain a regex char (#25136)
This is an automated email from the ASF dual-hosted git repository.
technoboy pushed a commit to branch branch-4.1
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/branch-4.1 by this push:
new 16e1bc45c1a [fix][broker] Fix regex matching of namespace name which might contain a regex char (#25136)
16e1bc45c1a is described below
commit 16e1bc45c1af9be55f53c41615549f4543cc9553
Author: Lari Hotari <lh...@users.noreply.github.com>
AuthorDate: Tue Jan 13 14:59:33 2026 +0200
[fix][broker] Fix regex matching of namespace name which might contain a regex char (#25136)
---
.../org/apache/pulsar/broker/resources/TopicResources.java | 4 ++--
.../apache/pulsar/broker/resources/TopicResourcesTest.java | 11 +++++++++++
2 files changed, 13 insertions(+), 2 deletions(-)
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 8ce4e5c8e20..de7596a7638 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
@@ -124,8 +124,8 @@ public class TopicResources {
}
Pattern namespaceNameToTopicNamePattern(NamespaceName namespaceName) {
- return Pattern.compile(
- MANAGED_LEDGER_PATH + "/(" + namespaceName + ")/(" + TopicDomain.persistent + ")/(" + "[^/]+)");
+ return Pattern.compile(MANAGED_LEDGER_PATH + "/(" + Pattern.quote(namespaceName.toString()) + ")/("
+ + TopicDomain.persistent + ")/(" + "[^/]+)");
}
public void registerPersistentTopicListener(
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 07a4ae195c8..48092e2a830 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
@@ -123,4 +123,15 @@ public class TopicResourcesTest {
verify(listener).accept("persistent://tenant/namespace/topic:test", NotificationType.Created);
}
+ @Test
+ public void testNamespaceContainsDotsShouldntMatchAny() {
+ BiConsumer<String, NotificationType> listener = mock(BiConsumer.class);
+ topicResources.registerPersistentTopicListener(NamespaceName.get("tenant/name.pace"), listener);
+ topicResources.handleNotification(new Notification(NotificationType.Created,
+ "/managed-ledgers/tenant/namespace/persistent/topic"));
+ verifyNoInteractions(listener);
+ topicResources.handleNotification(new Notification(NotificationType.Created,
+ "/managed-ledgers/tenant/name.pace/persistent/topic"));
+ verify(listener).accept("persistent://tenant/name.pace/topic", NotificationType.Created);
+ }
}