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 2020/01/21 21:29:10 UTC

[GitHub] [accumulo] ctubbsii commented on a change in pull request #1479: Clean up relative path code

ctubbsii commented on a change in pull request #1479: Clean up relative path code
URL: https://github.com/apache/accumulo/pull/1479#discussion_r369242513
 
 

 ##########
 File path: core/src/main/java/org/apache/accumulo/core/metadata/TabletFileUtil.java
 ##########
 @@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.accumulo.core.metadata;
+
+import org.apache.hadoop.fs.Path;
+
+/**
+ * Utility class for validation of metadata tablet files.
+ */
+public class TabletFileUtil {
+
+  /**
+   * Validate if string is a valid path. Return same string or throw exception if not valid. This
+   * was added to facilitate more use of TabletFile over String but this puts the validation in one
+   * location in the case where TabletFile can't be used.
+   */
+  public static String validate(String path) {
+    Path p = new Path(path);
+    if (p.toUri().getScheme() == null) {
+      throw new IllegalArgumentException("Invalid path provided, no scheme in " + path);
+    }
+    return path;
 
 Review comment:
   Did we want to have this normalize the path also by returning the normalized version from `Path`?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services