Skip to content

Commit

Permalink
[fix] Topic name from persistence naming encoding should url decode l…
Browse files Browse the repository at this point in the history
…ocal name
  • Loading branch information
Shawyeok committed Jun 7, 2024
1 parent fb80007 commit ce65db9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -358,17 +358,16 @@ public static String fromPersistenceNamingEncoding(String mlName) {
String localName;
if (parts.size() == 4) {
tenant = parts.get(0);
cluster = null;
namespacePortion = parts.get(1);
domain = parts.get(2);
localName = parts.get(3);
localName = Codec.decode(parts.get(3));
return String.format("%s://%s/%s/%s", domain, tenant, namespacePortion, localName);
} else if (parts.size() == 5) {
tenant = parts.get(0);
cluster = parts.get(1);
namespacePortion = parts.get(2);
domain = parts.get(3);
localName = parts.get(4);
localName = Codec.decode(parts.get(4));
return String.format("%s://%s/%s/%s/%s", domain, tenant, cluster, namespacePortion, localName);
} else {
throw new IllegalArgumentException("Invalid managedLedger name: " + mlName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,12 @@ public void testFromPersistenceNamingEncoding() {
} catch (IllegalArgumentException e) {
// Exception is expected.
}

// case5: local name with special characters e.g. a:b:c
String topicName = "persistent://tenant/namespace/a:b:c";
String persistentNamingEncoding = "tenant/namespace/persistent/a%3Ab%3Ac";
assertEquals(TopicName.get(topicName).getPersistenceNamingEncoding(), persistentNamingEncoding);
assertEquals(TopicName.fromPersistenceNamingEncoding(persistentNamingEncoding), topicName);
}


Expand Down

0 comments on commit ce65db9

Please sign in to comment.