From 2e9daa2e27536484846d9c5f020c6afaf27932ce Mon Sep 17 00:00:00 2001 From: Brahma Reddy Battula Date: Tue, 20 Jun 2017 20:44:31 +0800 Subject: [PATCH] HADOOP-14533. Size of args cannot be less than zero in TraceAdmin#run as its linkedlist. Contributed by Weisen Han. --- .../main/java/org/apache/hadoop/tracing/TraceAdmin.java | 2 +- .../java/org/apache/hadoop/tracing/TestTraceAdmin.java | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/tracing/TraceAdmin.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/tracing/TraceAdmin.java index 038435c6c37..766fb0a6557 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/tracing/TraceAdmin.java +++ b/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."); return 1; } - if (args.size() < 0) { + if (args.isEmpty()) { System.err.println("You must specify an operation."); return 1; } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/tracing/TestTraceAdmin.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/tracing/TestTraceAdmin.java index ad20310d01f..5a4d2a3e8fa 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/tracing/TestTraceAdmin.java +++ b/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(); } + @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 public void testCreateAndDestroySpanReceiver() throws Exception { Configuration conf = new Configuration();