浏览代码

HADOOP-8951. RunJar to fail with user-comprehensible error message if jar missing. Contributed by Steve Loughran.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1@1400931 13f79535-47bb-0310-9956-ffa450edef68
Suresh Srinivas 12 年之前
父节点
当前提交
c48c74125b
共有 2 个文件被更改,包括 7 次插入0 次删除
  1. 3 0
      CHANGES.txt
  2. 4 0
      src/core/org/apache/hadoop/util/RunJar.java

+ 3 - 0
CHANGES.txt

@@ -273,6 +273,9 @@ Release 1.2.0 - unreleased
     HDFS-4072. On file deletion remove corresponding blocks pending
     replications. (Jing Zhao via suresh)
 
+    HADOOP-8951. RunJar to fail with user-comprehensible error 
+    message if jar missing. (stevel via suresh)
+
 Release 1.1.1 - Unreleased
 
   INCOMPATIBLE CHANGES

+ 4 - 0
src/core/org/apache/hadoop/util/RunJar.java

@@ -81,6 +81,10 @@ public class RunJar {
     int firstArg = 0;
     String fileName = args[firstArg++];
     File file = new File(fileName);
+    if (!file.exists() || !file.isFile()) {
+      System.err.println("Not a valid JAR: " + file.getCanonicalPath());
+      System.exit(-1);
+    }
     String mainClassName = null;
 
     JarFile jarFile;