tschmidt64 opened a new issue #6619: Topic URL parser is incorrect URL: https://github.com/apache/pulsar/issues/6619 The code [in the web socket interface](https://github.com/apache/pulsar/blob/639fbf1801b227bb191cfc548f26906902481b8f/pulsar-websocket/src/main/java/org/apache/pulsar/websocket/AbstractWebSocketHandler.java#L182) does not parse topic names correctly. I will limit my example to a consumer but similar issues apply to readers and producers. From the code (line numbers are for reference, they do not match the actual code) ```java 1 String uri = request.getRequestURI(); 2 List<String> parts = Splitter.on("/").splitToList(uri); 3 4 // V1 Format must be like : 5 // /ws/producer/persistent/my-property/my-cluster/my-ns/my-topic 6 // or 7 // /ws/consumer/persistent/my-property/my-cluster/my-ns/my-topic/my-subscription 8 // or 9 // /ws/reader/persistent/my-property/my-cluster/my-ns/my-topic 10 11 // V2 Format must be like : 12 // /ws/v2/producer/persistent/my-property/my-ns/my-topic 13 // or 14 // /ws/v2/consumer/persistent/my-property/my-ns/my-topic/my-subscription 15 // or 16 // /ws/v2/reader/persistent/my-property/my-ns/my-topic 17 18 checkArgument(parts.size() >= 8, "Invalid topic name format"); 19 checkArgument(parts.get(1).equals("ws")); 20 21 final boolean isV2Format = parts.get(2).equals("v2"); 22 final int domainIndex = isV2Format ? 4 : 3; 23 checkArgument(parts.get(domainIndex).equals("persistent") || 24 parts.get(domainIndex).equals("non-persistent")); 25 26 27 final String domain = parts.get(domainIndex); 28 final NamespaceName namespace = isV2Format ? NamespaceName.get(parts.get(5), parts.get(6)) : 29 NamespaceName.get( parts.get(4), parts.get(5), parts.get(6)); 30 final String name = parts.get(7); 31 32 return TopicName.get(domain, namespace, name); 33 ``` As an breaking example, take the v2 web socket topic URL: ``` /ws/v2/consumer/persistent/public/default/my-ns/some-topic/sub/topic/my-sub ``` In the code above, the following assignments would be made ```java 27 domain = parts.get(4) ``` which translates to ```java 27 domain = parts.get("persistent") // this seems good ``` `namespace = NamespaceName.get(parts.get(5), parts.get(6))` translates to: `namespace = NamespaceName.get("public", "default")` **this doesn't seem right** `name` is `parts.get(7)` which is `
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to 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