1
0
Просмотр исходного кода

HADOOP-14533. Size of args cannot be less than zero in TraceAdmin#run as its linkedlist. Contributed by Weisen Han.

Brahma Reddy Battula 8 лет назад
Родитель
Сommit
2e9daa2e27

+ 1 - 1
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/tracing/TraceAdmin.java

@@ -166,7 +166,7 @@ public class TraceAdmin extends Configured implements Tool {
       System.err.println("You must specify a host with -host.");
       System.err.println("You must specify a host with -host.");
       return 1;
       return 1;
     }
     }
-    if (args.size() < 0) {
+    if (args.isEmpty()) {
       System.err.println("You must specify an operation.");
       System.err.println("You must specify an operation.");
       return 1;
       return 1;
     }
     }

+ 8 - 0
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/tracing/TestTraceAdmin.java

@@ -77,6 +77,14 @@ public class TestTraceAdmin extends SaslDataTransferTestCase {
     return "127.0.0.1:" + dns.get(index).getIpcPort();
     return "127.0.0.1:" + dns.get(index).getIpcPort();
   }
   }
 
 
+  @Test
+  public void testNoOperator() throws Exception {
+    TraceAdmin trace = new TraceAdmin();
+    trace.setConf(new Configuration());
+    Assert.assertEquals("ret:1, You must specify an operation." + NEWLINE,
+        runTraceCommand(trace, "-host", "127.0.0.1:12346"));
+  }
+
   @Test
   @Test
   public void testCreateAndDestroySpanReceiver() throws Exception {
   public void testCreateAndDestroySpanReceiver() throws Exception {
     Configuration conf = new Configuration();
     Configuration conf = new Configuration();