瀏覽代碼

HDFS-9159. [OIV] : return value of the command is not correct if invalid value specified in '-p (processor)' option (Contributed by nijel)

(cherry picked from commit 61b3547c462a4e51d0a31c0a8c8ce210e2d90df8)
Vinayakumar B 9 年之前
父節點
當前提交
2b6fe90764

+ 3 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

@@ -1160,6 +1160,9 @@ Release 2.8.0 - UNRELEASED
 
     HDFS-9196. Fix TestWebHdfsContentLength. (Masatake Iwasaki via jing9)
 
+    HDFS-9159. [OIV] : return value of the command is not correct if invalid
+    value specified in "-p (processor)" option (nijel via vinayakumarb)
+
 Release 2.7.2 - UNRELEASED
 
   INCOMPATIBLE CHANGES

+ 4 - 0
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/OfflineImageViewerPB.java

@@ -182,6 +182,10 @@ public class OfflineImageViewerPB {
             writer.visit(new RandomAccessFile(inputFile, "r"));
           }
           break;
+        default:
+          System.err.println("Invalid processor specified : " + processor);
+          printUsage();
+          return -1;
       }
       return 0;
     } catch (EOFException e) {

+ 9 - 0
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java

@@ -341,6 +341,15 @@ public class TestOfflineImageViewer {
         new FileSystemTestHelper().getTestRootDir() + "/delimited.db");
   }
 
+  @Test
+  public void testInvalidProcessorOption() throws Exception {
+    int status =
+        OfflineImageViewerPB.run(new String[] { "-i",
+            originalFsimage.getAbsolutePath(), "-o", "-", "-p", "invalid" });
+    assertTrue("Exit code returned for invalid processor option is incorrect",
+        status != 0);
+  }
+
   private void testPBDelimitedWriter(String db)
       throws IOException, InterruptedException {
     final String DELIMITER = "\t";