poorbarcode commented on code in PR #23049:
URL: https://github.com/apache/pulsar/pull/23049#discussion_r1683255386
##########
pulsar-common/src/main/java/org/apache/pulsar/common/naming/SystemTopicNames.java:
##########
@@ -91,8 +104,23 @@ public static boolean isTransactionInternalName(TopicName
topicName) {
|| topic.endsWith(PENDING_ACK_STORE_SUFFIX);
}
+ public static boolean isTransactionInternalLocalName(String
localTopicName) {
+ return TRANSACTION_COORDINATOR_ASSIGN_LOCAL_NAME.equals(localTopicName)
+ ||
TRANSACTION_COORDINATOR_LOG_LOCAL_NAME.equals(localTopicName)
+ || PENDING_ACK_STORE_SUFFIX.equals(localTopicName);
+ }
+
public static boolean isSystemTopic(TopicName topicName) {
- TopicName nonPartitionedTopicName =
TopicName.get(topicName.getPartitionedTopicName());
- return isEventSystemTopic(nonPartitionedTopicName) ||
isTransactionInternalName(nonPartitionedTopicName);
+ int partition = topicName.getPartitionIndex();
+ String localTopicName = topicName.getLocalName();
+ if (partition >= 0) {
+ int suffixLen = PARTITIONED_TOPIC_SUFFIX.length() +
String.valueOf(partition).length();
+ if (localTopicName.length() <= suffixLen) {
+ log.error("Found an error topic name: {}", topicName);
+ throw new IllegalArgumentException("Found an error topic name:
" + topicName.toString());
+ }
+ localTopicName = localTopicName.substring(0,
localTopicName.length() - suffixLen);
+ }
+ return isEventSystemTopicLocalName(localTopicName) ||
isTransactionInternalLocalName(localTopicName);
Review Comment:
To avoid creating `TopicName` object. After tests, it is not important, so
I removed this improvement
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]