HADOOP-9924. FileUtil.createJarWithClassPath() does not generate relative classpath correctly. Contributed by Shanyu Zhao.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1519891 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Ivan Mitic 2013-09-04 01:16:04 +00:00
parent 2d525510b4
commit b87bcbb82d
3 changed files with 27 additions and 8 deletions

View File

@ -444,6 +444,9 @@ Release 2.1.1-beta - UNRELEASED
HADOOP-9774. RawLocalFileSystem.listStatus() return absolute paths when HADOOP-9774. RawLocalFileSystem.listStatus() return absolute paths when
input path is relative on Windows. (Shanyu Zhao via ivanmi) input path is relative on Windows. (Shanyu Zhao via ivanmi)
HADOOP-9924. FileUtil.createJarWithClassPath() does not generate relative
classpath correctly. (Shanyu Zhao via ivanmi)
Release 2.1.0-beta - 2013-08-22 Release 2.1.0-beta - 2013-08-22
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -1252,7 +1252,14 @@ public class FileUtil {
} }
} else { } else {
// Append just this entry // Append just this entry
String classPathEntryUrl = new File(classPathEntry).toURI().toURL() File fileCpEntry = null;
if(!new Path(classPathEntry).isAbsolute()) {
fileCpEntry = new File(workingDir, classPathEntry);
}
else {
fileCpEntry = new File(classPathEntry);
}
String classPathEntryUrl = fileCpEntry.toURI().toURL()
.toExternalForm(); .toExternalForm();
// File.toURI only appends trailing '/' if it can determine that it is a // File.toURI only appends trailing '/' if it can determine that it is a

View File

@ -782,16 +782,25 @@ public class TestFileUtil {
expectedClassPaths.add(wildcardMatch.toURI().toURL() expectedClassPaths.add(wildcardMatch.toURI().toURL()
.toExternalForm()); .toExternalForm());
} }
} else if (nonExistentSubdir.equals(classPath)) { } else {
File fileCp = null;
if(!new Path(classPath).isAbsolute()) {
fileCp = new File(tmp, classPath);
}
else {
fileCp = new File(classPath);
}
if (nonExistentSubdir.equals(classPath)) {
// expect to maintain trailing path separator if present in input, even // expect to maintain trailing path separator if present in input, even
// if directory doesn't exist yet // if directory doesn't exist yet
expectedClassPaths.add(new File(classPath).toURI().toURL() expectedClassPaths.add(fileCp.toURI().toURL()
.toExternalForm() + Path.SEPARATOR); .toExternalForm() + Path.SEPARATOR);
} else { } else {
expectedClassPaths.add(new File(classPath).toURI().toURL() expectedClassPaths.add(fileCp.toURI().toURL()
.toExternalForm()); .toExternalForm());
} }
} }
}
List<String> actualClassPaths = Arrays.asList(classPathAttr.split(" ")); List<String> actualClassPaths = Arrays.asList(classPathAttr.split(" "));
Collections.sort(expectedClassPaths); Collections.sort(expectedClassPaths);
Collections.sort(actualClassPaths); Collections.sort(actualClassPaths);