merlimat closed pull request #2836: Fix: schema init for topic-name with 
special char
URL: https://github.com/apache/pulsar/pull/2836
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BrokerBkEnsemblesTests.java
 
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BrokerBkEnsemblesTests.java
index cc82ff4c55..b7303c65aa 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BrokerBkEnsemblesTests.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BrokerBkEnsemblesTests.java
@@ -70,8 +70,7 @@
 
     LocalBookkeeperEnsemble bkEnsemble;
 
-    private final int ZOOKEEPER_PORT = PortManager.nextFreePort();
-    protected final int BROKER_WEBSERVICE_PORT = PortManager.nextFreePort();
+    protected int BROKER_WEBSERVICE_PORT;
 
     private final int numberOfBookies;
 
@@ -86,6 +85,8 @@ public BrokerBkEnsemblesTests(int numberOfBookies) {
     @BeforeMethod
     protected void setup() throws Exception {
         try {
+            int ZOOKEEPER_PORT = PortManager.nextFreePort();
+            BROKER_WEBSERVICE_PORT = PortManager.nextFreePort();
             // start local bookie and zookeeper
             bkEnsemble = new LocalBookkeeperEnsemble(numberOfBookies, 
ZOOKEEPER_PORT, () -> PortManager.nextFreePort());
             bkEnsemble.start();
@@ -340,5 +341,32 @@ public void testSkipCorruptDataLedger() throws Exception {
         client.close();
     }
 
+    @Test(timeOut=20000)
+    public void testTopicWithWildCardChar() throws Exception {
+        PulsarClient client = 
PulsarClient.builder().serviceUrl(adminUrl.toString()).statsInterval(0, 
TimeUnit.SECONDS)
+                .build();
+
+        final String ns1 = "prop/usc/topicWithSpecialChar";
+        try {
+            admin.namespaces().createNamespace(ns1);
+        } catch (Exception e) {
+
+        }
+        
+        final String topic1 = 
"persistent://"+ns1+"/`~!@#$%^&*()-_+=[]://{}|\\;:'\"<>,./?-30e04524";
+        final String subName1 = "c1";
+        final byte[] content = "test".getBytes();
+
+        Consumer<byte[]> consumer = 
client.newConsumer().topic(topic1).subscriptionName(subName1).subscribe();
+        org.apache.pulsar.client.api.Producer<byte[]> producer = 
client.newProducer().topic(topic1).create();
+
+        producer.send(content);
+        Message<byte[]> msg = consumer.receive();
+        Assert.assertEquals(msg.getData(), content);
+        consumer.close();
+        producer.close();
+        client.close();
+    }
+
     private static final Logger LOG = 
LoggerFactory.getLogger(BrokerBkEnsemblesTests.class);
 }
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/RackAwareTest.java
 
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/RackAwareTest.java
index ada7b9f171..daa6fe5ee9 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/RackAwareTest.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/RackAwareTest.java
@@ -130,5 +130,10 @@ public void testSkipCorruptDataLedger() throws Exception {
         // Ignore test
     }
 
+    @Test(enabled = false)
+    public void testTopicWithWildCardChar() throws Exception {
+        // Ignore test
+    }
+    
     private static final Logger log = 
LoggerFactory.getLogger(RackAwareTest.class);
 }
diff --git 
a/pulsar-common/src/main/java/org/apache/pulsar/common/naming/TopicName.java 
b/pulsar-common/src/main/java/org/apache/pulsar/common/naming/TopicName.java
index bde252c107..eef05f3b18 100644
--- a/pulsar-common/src/main/java/org/apache/pulsar/common/naming/TopicName.java
+++ b/pulsar-common/src/main/java/org/apache/pulsar/common/naming/TopicName.java
@@ -337,7 +337,7 @@ public boolean isGlobal() {
     public String getSchemaName() {
         return getTenant()
             + "/" + getNamespacePortion()
-            + "/" + getLocalName();
+            + "/" + getEncodedLocalName();
     }
 
     @Override


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to