HADOOP-7377. Fix command name handling affecting DFSAdmin. Contributed by Daryn Sharp.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1136223 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7728f03f08
commit
4c290b51fa
|
@ -315,6 +315,9 @@ Trunk (unreleased changes)
|
||||||
HADOOP-7390. VersionInfo not generated properly in git after unsplit. (todd
|
HADOOP-7390. VersionInfo not generated properly in git after unsplit. (todd
|
||||||
via atm)
|
via atm)
|
||||||
|
|
||||||
|
HADOOP-7377. Fix command name handling affecting DFSAdmin. (Daryn Sharp
|
||||||
|
via mattf)
|
||||||
|
|
||||||
Release 0.22.0 - Unreleased
|
Release 0.22.0 - Unreleased
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.hadoop.fs.shell;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
@ -378,7 +379,7 @@ abstract public class Command extends Configured {
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return (name == null)
|
return (name == null)
|
||||||
? getCommandField("NAME")
|
? getCommandField("NAME")
|
||||||
: name.startsWith("-") ? name.substring(1) : name; // this is a historical method
|
: name.startsWith("-") ? name.substring(1) : name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -433,7 +434,9 @@ abstract public class Command extends Configured {
|
||||||
private String getCommandField(String field) {
|
private String getCommandField(String field) {
|
||||||
String value;
|
String value;
|
||||||
try {
|
try {
|
||||||
value = this.getClass().getField(field).get(this).toString();
|
Field f = this.getClass().getDeclaredField(field);
|
||||||
|
f.setAccessible(true);
|
||||||
|
value = f.get(this).toString();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
"failed to get " + this.getClass().getSimpleName()+"."+field, e);
|
"failed to get " + this.getClass().getSimpleName()+"."+field, e);
|
||||||
|
|
Loading…
Reference in New Issue