jerryshao commented on code in PR #7535:
URL: https://github.com/apache/gravitino/pull/7535#discussion_r2181412706
##########
api/src/main/java/org/apache/gravitino/Namespace.java:
##########
@@ -72,8 +74,17 @@ public static Namespace of(String... levels) {
* @return A namespace with the given levels
*/
public static Namespace fromString(String namespace) {
- // todo: escape the dots in the levels if needed
- return new Namespace(namespace.split("\\."));
+ Preconditions.checkArgument(namespace != null, "Cannot create a namespace
with null input");
+ Preconditions.checkArgument(!namespace.endsWith("."), "Cannot create a
namespace end with dot");
+ if (StringUtils.isBlank(namespace)) {
+ return empty();
+ }
+ String[] levels = namespace.split("\\.");
+ for (String level : levels) {
+ Preconditions.checkArgument(
+ StringUtils.isNotEmpty(level), "Cannot create a namespace with null
or empty level");
+ }
+ return new Namespace(levels);
Review Comment:
Some logic here is duplicated with `Namespace of(String... levels)`, we
should call that method after the `levels` is splitted.
--
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]