Skip to content

Commit

Permalink
[fix][misc] Topic name from persistence name should decode local name (
Browse files Browse the repository at this point in the history
…apache#22879)

(cherry picked from commit c326d8e)
  • Loading branch information
Shawyeok authored and lhotari committed Jun 13, 2024
1 parent 77966e2 commit dae7d8b
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 dae7d8b

Please sign in to comment.