You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2022/10/18 11:32:04 UTC

[GitHub] [accumulo] dlmarion commented on a diff in pull request #3003: remove extra node in prop path

dlmarion commented on code in PR #3003:
URL: https://github.com/apache/accumulo/pull/3003#discussion_r998066008


##########
server/base/src/main/java/org/apache/accumulo/server/conf/store/PropStoreKey.java:
##########
@@ -89,25 +89,44 @@ protected PropStoreKey(final InstanceId instanceId, final String path, final ID_
    */
   public static @Nullable PropStoreKey<?> fromPath(final String path) {
     String[] tokens = path.split("/");
+    if (tokens.length < 1) {
+      return null;
+    }
 
     InstanceId instanceId;
     try {
       instanceId = InstanceId.of(tokens[IID_TOKEN_POSITION]);
+
+      // needs to start with /accumulo/[instanceId]
+      if (!path.startsWith(ZooUtil.getRoot(instanceId))) {
+        log.warn(
+            "Path '{}' is invalid for a property cache key, expected to start with /accumulo/[instance_id]",

Review Comment:
   Is there a reason not to put the actual instanceId in the warning message?



##########
server/base/src/main/java/org/apache/accumulo/server/conf/store/PropStoreKey.java:
##########
@@ -89,25 +89,44 @@ protected PropStoreKey(final InstanceId instanceId, final String path, final ID_
    */
   public static @Nullable PropStoreKey<?> fromPath(final String path) {
     String[] tokens = path.split("/");
+    if (tokens.length < 1) {
+      return null;
+    }
 
     InstanceId instanceId;
     try {
       instanceId = InstanceId.of(tokens[IID_TOKEN_POSITION]);
+

Review Comment:
   Alternatively, you could remove the try/catch here and check that tokens.length equals EXPECTED_CONFIG_LEN or EXPECTED_SYS_CONFIG_LEN.



-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org