Skip to content

Commit

Permalink
HBASE-19549 Change path comparison in CommonFSUtils
Browse files Browse the repository at this point in the history
Also change makeQualified(FileSystem fs)
to makeQualified(URI defaultUri, Path workingDir)

Signed-off-by: Michael Stack <stack@apache.org>
  • Loading branch information
petersomogyi authored and saintstack committed Dec 18, 2017
1 parent b4056d2 commit abae907
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Expand Up @@ -356,7 +356,7 @@ public static String getPath(Path p) {
public static Path getRootDir(final Configuration c) throws IOException { public static Path getRootDir(final Configuration c) throws IOException {
Path p = new Path(c.get(HConstants.HBASE_DIR)); Path p = new Path(c.get(HConstants.HBASE_DIR));
FileSystem fs = p.getFileSystem(c); FileSystem fs = p.getFileSystem(c);
return p.makeQualified(fs); return p.makeQualified(fs.getUri(), fs.getWorkingDirectory());
} }


public static void setRootDir(final Configuration c, final Path root) throws IOException { public static void setRootDir(final Configuration c, final Path root) throws IOException {
Expand Down Expand Up @@ -384,7 +384,7 @@ public static Path getWALRootDir(final Configuration c) throws IOException {
return getRootDir(c); return getRootDir(c);
} }
FileSystem fs = p.getFileSystem(c); FileSystem fs = p.getFileSystem(c);
return p.makeQualified(fs); return p.makeQualified(fs.getUri(), fs.getWorkingDirectory());
} }


@VisibleForTesting @VisibleForTesting
Expand All @@ -399,8 +399,10 @@ public static FileSystem getWALFileSystem(final Configuration c) throws IOExcept


private static boolean isValidWALRootDir(Path walDir, final Configuration c) throws IOException { private static boolean isValidWALRootDir(Path walDir, final Configuration c) throws IOException {
Path rootDir = getRootDir(c); Path rootDir = getRootDir(c);
if (!walDir.equals(rootDir)) { FileSystem fs = walDir.getFileSystem(c);
if (walDir.toString().startsWith(rootDir.toString() + "/")) { Path qualifiedWalDir = walDir.makeQualified(fs.getUri(), fs.getWorkingDirectory());
if (!qualifiedWalDir.equals(rootDir)) {
if (qualifiedWalDir.toString().startsWith(rootDir.toString() + "/")) {
throw new IllegalStateException("Illegal WAL directory specified. " + throw new IllegalStateException("Illegal WAL directory specified. " +
"WAL directories are not permitted to be under the root directory if set."); "WAL directories are not permitted to be under the root directory if set.");
} }
Expand Down
Expand Up @@ -965,7 +965,7 @@ private static Path findOrCreateJar(Class<?> my_class, FileSystem fs,
} }


LOG.debug(String.format("For class %s, using jar %s", my_class.getName(), jar)); LOG.debug(String.format("For class %s, using jar %s", my_class.getName(), jar));
return new Path(jar).makeQualified(fs); return new Path(jar).makeQualified(fs.getUri(), fs.getWorkingDirectory());
} }


/** /**
Expand Down

0 comments on commit abae907

Please sign in to comment.