smiklosovic commented on code in PR #4038: URL: https://github.com/apache/cassandra/pull/4038#discussion_r2060803095
########## src/java/org/apache/cassandra/schema/TableMetadata.java: ########## @@ -602,11 +606,16 @@ public boolean dependsOn(Function function) public void validate() { - if (!isNameValid(keyspace)) - except("Keyspace name must not be empty, more than %s characters long, or contain non-alphanumeric-underscore characters (got \"%s\")", SchemaConstants.NAME_LENGTH, keyspace); + if (!isValidKeyspaceName(keyspace)) + except("Keyspace name must not be empty, more than %s characters long, or contain non-alphanumeric-underscore characters (got \"%s\")", NAME_LENGTH, keyspace); Review Comment: what I would prefer to do is to move "except" into "isValidKeyspaceName". If we always throw when we check, why not to move throwing to that method? Same for table version of it (together with "assert" after checking logic) That would lead to the renaming of these methods to "validateKeyspaceName(String)" and "validateTableName(String)". This stuff in here would be reduced to two method calls. SchemaConstants should contain this helper logic. We would just call it from there here. ########## src/java/org/apache/cassandra/schema/TableMetadata.java: ########## @@ -602,11 +606,16 @@ public boolean dependsOn(Function function) public void validate() { - if (!isNameValid(keyspace)) - except("Keyspace name must not be empty, more than %s characters long, or contain non-alphanumeric-underscore characters (got \"%s\")", SchemaConstants.NAME_LENGTH, keyspace); + if (!isValidKeyspaceName(keyspace)) + except("Keyspace name must not be empty, more than %s characters long, or contain non-alphanumeric-underscore characters (got \"%s\")", NAME_LENGTH, keyspace); Review Comment: what I would prefer to do is to move "except" into "isValidKeyspaceName". If we always throw when we check, why not to move throwing to that method? Same for table version of it (together with "assert" after checking logic) That would lead to the renaming of these methods to "validateKeyspaceName(String)" and "validateTableName(String)". This stuff in here would be reduced to two method calls. SchemaConstants should contain this whole helper logic. We would just call it from there here. -- 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: pr-unsubscr...@cassandra.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org For additional commands, e-mail: pr-h...@cassandra.apache.org