MAPREDUCE-7114. Make FrameworkUploader symlink ignore improvement. Contributed by Gergo Repas.

This commit is contained in:
Miklos Szegedi 2018-06-22 13:05:41 -07:00
parent 55fad6a3de
commit ae055622ed
2 changed files with 14 additions and 1 deletions

View File

@ -409,7 +409,7 @@ boolean checkSymlink(File jar) {
linkPath == null ? null : linkPath.getParent(); linkPath == null ? null : linkPath.getParent();
java.nio.file.Path normalizedLinkPath = java.nio.file.Path normalizedLinkPath =
linkPathParent == null ? null : linkPathParent.normalize(); linkPathParent == null ? null : linkPathParent.normalize();
if (normalizedLinkPath != null && jarParent.equals( if (normalizedLinkPath != null && jarParent.normalize().equals(
normalizedLinkPath)) { normalizedLinkPath)) {
LOG.info(String.format("Ignoring same directory link %s to %s", LOG.info(String.format("Ignoring same directory link %s to %s",
jarPath.toString(), link.toString())); jarPath.toString(), link.toString()));

View File

@ -440,6 +440,19 @@ public void testNativeIO() throws IOException {
} }
Assert.assertTrue(uploader.checkSymlink(symlinkToTarget)); Assert.assertTrue(uploader.checkSymlink(symlinkToTarget));
// Create a symlink to the target with /./ in the path
symlinkToTarget = new File(parent.getAbsolutePath() +
"/./symlinkToTarget2.txt");
try {
Files.createSymbolicLink(
Paths.get(symlinkToTarget.getAbsolutePath()),
Paths.get(targetFile.getAbsolutePath()));
} catch (UnsupportedOperationException e) {
// Symlinks are not supported, so ignore the test
Assume.assumeTrue(false);
}
Assert.assertTrue(uploader.checkSymlink(symlinkToTarget));
// Create a symlink outside the current directory // Create a symlink outside the current directory
File symlinkOutside = new File(parent, "symlinkToParent.txt"); File symlinkOutside = new File(parent, "symlinkToParent.txt");
try { try {