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

This commit is contained in:
Brahma Reddy Battula 2017-06-20 20:44:31 +08:00
parent 099dfe92a9
commit 2e9daa2e27
2 changed files with 9 additions and 1 deletions

View File

@ -166,7 +166,7 @@ public int run(String argv[]) throws Exception {
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;
} }

View File

@ -77,6 +77,14 @@ private String getHostPortForDN(MiniDFSCluster cluster, int index) {
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();