You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ma...@apache.org on 2011/06/16 00:24:07 UTC

svn commit: r1136223 - in /hadoop/common/trunk/common: CHANGES.txt src/java/org/apache/hadoop/fs/shell/Command.java

Author: mattf
Date: Wed Jun 15 22:24:07 2011
New Revision: 1136223

URL: http://svn.apache.org/viewvc?rev=1136223&view=rev
Log:
HADOOP-7377. Fix command name handling affecting DFSAdmin. Contributed by Daryn Sharp.

Modified:
    hadoop/common/trunk/common/CHANGES.txt
    hadoop/common/trunk/common/src/java/org/apache/hadoop/fs/shell/Command.java

Modified: hadoop/common/trunk/common/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/common/CHANGES.txt?rev=1136223&r1=1136222&r2=1136223&view=diff
==============================================================================
--- hadoop/common/trunk/common/CHANGES.txt (original)
+++ hadoop/common/trunk/common/CHANGES.txt Wed Jun 15 22:24:07 2011
@@ -315,6 +315,9 @@ Trunk (unreleased changes)
     HADOOP-7390. VersionInfo not generated properly in git after unsplit. (todd
     via atm)
 
+    HADOOP-7377. Fix command name handling affecting DFSAdmin. (Daryn Sharp
+    via mattf)
+
 Release 0.22.0 - Unreleased
 
   INCOMPATIBLE CHANGES

Modified: hadoop/common/trunk/common/src/java/org/apache/hadoop/fs/shell/Command.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/common/src/java/org/apache/hadoop/fs/shell/Command.java?rev=1136223&r1=1136222&r2=1136223&view=diff
==============================================================================
--- hadoop/common/trunk/common/src/java/org/apache/hadoop/fs/shell/Command.java (original)
+++ hadoop/common/trunk/common/src/java/org/apache/hadoop/fs/shell/Command.java Wed Jun 15 22:24:07 2011
@@ -20,6 +20,7 @@ package org.apache.hadoop.fs.shell;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.PrintStream;
+import java.lang.reflect.Field;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.LinkedList;
@@ -378,7 +379,7 @@ abstract public class Command extends Co
   public String getName() {
     return (name == null)
       ? 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 Co
   private String getCommandField(String field) {
     String value;
     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) {
       throw new RuntimeException(
           "failed to get " + this.getClass().getSimpleName()+"."+field, e);