apoorvmittal10 commented on code in PR #17660:
URL: https://github.com/apache/kafka/pull/17660#discussion_r1828281126
##########
share/src/main/java/org/apache/kafka/server/share/SharePartitionKey.java:
##########
@@ -72,6 +72,21 @@ public static SharePartitionKey getInstance(String groupId,
TopicIdPartition top
* @return object representing SharePartitionKey
*/
public static SharePartitionKey getInstance(String key) {
+ validate(key);
+ String[] tokens = key.split(":");
+ return new SharePartitionKey(
+ tokens[0],
Review Comment:
Should we trim here as we did while validating?
```
tokens[0].trim(),
##########
share/src/main/java/org/apache/kafka/server/share/SharePartitionKey.java:
##########
@@ -72,6 +72,21 @@ public static SharePartitionKey getInstance(String groupId,
TopicIdPartition top
* @return object representing SharePartitionKey
*/
public static SharePartitionKey getInstance(String key) {
+ validate(key);
+ String[] tokens = key.split(":");
+ return new SharePartitionKey(
+ tokens[0],
+ Uuid.fromString(tokens[1]),
+ Integer.parseInt(tokens[2])
+ );
+ }
+
+ /**
+ * Validates whether the String argument has a valid SharePartitionKey
format - groupId:topicId:partition
+ * @param key - String in format groupId:topicId:partition
+ * @exception IllegalArgumentException if the key is empty or has invalid
format
Review Comment:
In Kafka I have seen usage of @throws instead of @exception, with an
exception in only one class. Though they are synonyms in java but shall we
follw the general way?
##########
share/src/main/java/org/apache/kafka/server/share/SharePartitionKey.java:
##########
@@ -72,6 +72,21 @@ public static SharePartitionKey getInstance(String groupId,
TopicIdPartition top
* @return object representing SharePartitionKey
Review Comment:
Also @throws here as validate method is called.
--
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]