HADOOP-9924. Merging addendum change r1520903 from trunk

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1520904 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Ivan Mitic 2013-09-08 19:57:58 +00:00
parent cc4927d4af
commit 9fed38f149
2 changed files with 7 additions and 1 deletions

View File

@ -1239,6 +1239,9 @@ public static String createJarWithClassPath(String inputClassPath, Path pwd,
List<String> classPathEntryList = new ArrayList<String>( List<String> classPathEntryList = new ArrayList<String>(
classPathEntries.length); classPathEntries.length);
for (String classPathEntry: classPathEntries) { for (String classPathEntry: classPathEntries) {
if (classPathEntry.length() == 0) {
continue;
}
if (classPathEntry.endsWith("*")) { if (classPathEntry.endsWith("*")) {
// Append all jars that match the wildcard // Append all jars that match the wildcard
Path globPath = new Path(classPathEntry).suffix("{.jar,.JAR}"); Path globPath = new Path(classPathEntry).suffix("{.jar,.JAR}");

View File

@ -757,7 +757,7 @@ public void testCreateJarWithClassPath() throws Exception {
String wildcardPath = tmp.getCanonicalPath() + File.separator + "*"; String wildcardPath = tmp.getCanonicalPath() + File.separator + "*";
String nonExistentSubdir = tmp.getCanonicalPath() + Path.SEPARATOR + "subdir" String nonExistentSubdir = tmp.getCanonicalPath() + Path.SEPARATOR + "subdir"
+ Path.SEPARATOR; + Path.SEPARATOR;
List<String> classPaths = Arrays.asList("cp1.jar", "cp2.jar", wildcardPath, List<String> classPaths = Arrays.asList("", "cp1.jar", "cp2.jar", wildcardPath,
"cp3.jar", nonExistentSubdir); "cp3.jar", nonExistentSubdir);
String inputClassPath = StringUtils.join(File.pathSeparator, classPaths); String inputClassPath = StringUtils.join(File.pathSeparator, classPaths);
String classPathJar = FileUtil.createJarWithClassPath(inputClassPath, String classPathJar = FileUtil.createJarWithClassPath(inputClassPath,
@ -776,6 +776,9 @@ public void testCreateJarWithClassPath() throws Exception {
Assert.assertNotNull(classPathAttr); Assert.assertNotNull(classPathAttr);
List<String> expectedClassPaths = new ArrayList<String>(); List<String> expectedClassPaths = new ArrayList<String>();
for (String classPath: classPaths) { for (String classPath: classPaths) {
if (classPath.length() == 0) {
continue;
}
if (wildcardPath.equals(classPath)) { if (wildcardPath.equals(classPath)) {
// add wildcard matches // add wildcard matches
for (File wildcardMatch: wildcardMatches) { for (File wildcardMatch: wildcardMatches) {