diqiu50 commented on code in PR #14575:
URL: https://github.com/apache/gravitino/pull/14575#discussion_r4463235877
##########
catalogs/catalog-kafka/src/main/java/org/apache/gravitino/catalog/kafka/KafkaCatalogCapability.java:
##########
@@ -23,6 +23,8 @@
import org.apache.gravitino.connector.capability.CapabilityResult;
public class KafkaCatalogCapability implements Capability {
+ private static final String TOPIC_NAME_PATTERN = "[a-zA-Z0-9._-]+";
Review Comment:
After the default check, this pattern can only reject `/` and `=`. A direct
`indexOf` check would be clearer and removes this constant.
##########
catalogs/catalog-kafka/src/main/java/org/apache/gravitino/catalog/kafka/KafkaCatalogCapability.java:
##########
@@ -31,4 +33,25 @@ public CapabilityResult managedStorage(Scope scope) {
return CapabilityResult.unsupported(
String.format("Kafka catalog does not support managed storage for
%s.", scope));
}
+
+ /**
+ * Checks names against Gravitino's default rules and Kafka's topic
character restrictions.
+ *
+ * @param scope The scope of the capability.
+ * @param name The name to check.
+ * @return Whether the name is supported in the given scope.
+ */
+ @Override
+ public CapabilityResult specificationOnName(Scope scope, String name) {
+ CapabilityResult result = Capability.super.specificationOnName(scope,
name);
+ if (!result.supported() || scope != Scope.TOPIC) {
+ return result;
+ }
+
+ if (!name.matches(TOPIC_NAME_PATTERN)) {
+ return CapabilityResult.unsupported(
+ "Kafka topic names must contain only ASCII alphanumerics, '.', '_'
and '-'.");
Review Comment:
The default check already rejects `.` and a leading `-`, so this message is
misleading: `a.b` still fails after a user follows it. Suggest: "Kafka topic
names must not contain '/' or '='."
--
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]