HADOOP-7204. remove local unused fs variable from CmdHandler and FsShellPermissions.changePermissions

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1084415 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Boris Shkolnik 2011-03-22 23:54:29 +00:00
parent 0d55e1a144
commit 151c1a7952
4 changed files with 20 additions and 15 deletions

View File

@ -121,6 +121,9 @@ Trunk (unreleased changes)
HADOOP-6912. Guard against NPE when calling UGI.isLoginKeytabBased(). HADOOP-6912. Guard against NPE when calling UGI.isLoginKeytabBased().
(Kan Zhang via jitendra) (Kan Zhang via jitendra)
HADOOP-7204. remove local unused fs variable from CmdHandler
and FsShellPermissions.changePermissions (boryas)
Release 0.22.0 - Unreleased Release 0.22.0 - Unreleased
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -1263,7 +1263,7 @@ public class FsShell extends Configured implements Tool {
boolean okToContinue() { return okToContinue; } boolean okToContinue() { return okToContinue; }
String getName() { return cmdName; } String getName() { return cmdName; }
protected CmdHandler(String cmdName, FileSystem fs) { protected CmdHandler(String cmdName) {
this.cmdName = cmdName; this.cmdName = cmdName;
} }
@ -1911,7 +1911,7 @@ public class FsShell extends Configured implements Tool {
} else if ("-chmod".equals(cmd) || } else if ("-chmod".equals(cmd) ||
"-chown".equals(cmd) || "-chown".equals(cmd) ||
"-chgrp".equals(cmd)) { "-chgrp".equals(cmd)) {
exitCode = FsShellPermissions.changePermissions(fs, cmd, argv, i, this); exitCode = FsShellPermissions.changePermissions(cmd, argv, i, this);
} else if ("-ls".equals(cmd)) { } else if ("-ls".equals(cmd)) {
if (i < argv.length) { if (i < argv.length) {
exitCode = doall(cmd, argv, i); exitCode = doall(cmd, argv, i);

View File

@ -55,8 +55,8 @@ class FsShellPermissions {
private static class ChmodHandler extends CmdHandler { private static class ChmodHandler extends CmdHandler {
ChmodHandler(FileSystem fs, String modeStr) throws IOException { ChmodHandler(String modeStr) throws IOException {
super("chmod", fs); super("chmod");
try { try {
pp = new ChmodParser(modeStr); pp = new ChmodParser(modeStr);
} catch(IllegalArgumentException iea) { } catch(IllegalArgumentException iea) {
@ -103,12 +103,14 @@ class FsShellPermissions {
protected String owner = null; protected String owner = null;
protected String group = null; protected String group = null;
protected ChownHandler(String cmd, FileSystem fs) { //for chgrp protected ChownHandler(String cmd) { //for chgrp
super(cmd, fs); super(cmd);
} }
ChownHandler(FileSystem fs, String ownerStr) throws IOException { ChownHandler(String cmd, String ownerStr) throws IOException {
super("chown", fs); super(cmd);
if(!cmd.equals("chown"))
return;
Matcher matcher = chownPattern.matcher(ownerStr); Matcher matcher = chownPattern.matcher(ownerStr);
if (!matcher.matches()) { if (!matcher.matches()) {
throw new IOException("'" + ownerStr + "' does not match " + throw new IOException("'" + ownerStr + "' does not match " +
@ -149,8 +151,8 @@ class FsShellPermissions {
/*========== chgrp ==========*/ /*========== chgrp ==========*/
private static class ChgrpHandler extends ChownHandler { private static class ChgrpHandler extends ChownHandler {
ChgrpHandler(FileSystem fs, String groupStr) throws IOException { ChgrpHandler(String groupStr) throws IOException {
super("chgrp", fs); super("chgrp");
Matcher matcher = chgrpPattern.matcher(groupStr); Matcher matcher = chgrpPattern.matcher(groupStr);
if (!matcher.matches()) { if (!matcher.matches()) {
@ -161,7 +163,7 @@ class FsShellPermissions {
} }
} }
static int changePermissions(FileSystem fs, String cmd, static int changePermissions(String cmd,
String argv[], int startIndex, FsShell shell) String argv[], int startIndex, FsShell shell)
throws IOException { throws IOException {
CmdHandler handler = null; CmdHandler handler = null;
@ -178,11 +180,11 @@ class FsShellPermissions {
} }
if (cmd.equals("-chmod")) { if (cmd.equals("-chmod")) {
handler = new ChmodHandler(fs, argv[startIndex++]); handler = new ChmodHandler(argv[startIndex++]);
} else if (cmd.equals("-chown")) { } else if (cmd.equals("-chown")) {
handler = new ChownHandler(fs, argv[startIndex++]); handler = new ChownHandler(argv[startIndex++]);
} else if (cmd.equals("-chgrp")) { } else if (cmd.equals("-chgrp")) {
handler = new ChgrpHandler(fs, argv[startIndex++]); handler = new ChgrpHandler(argv[startIndex++]);
} }
return shell.runCmdHandler(handler, argv, startIndex, recursive); return shell.runCmdHandler(handler, argv, startIndex, recursive);

View File

@ -51,7 +51,7 @@ public class TestFsShellReturnCode {
public void verify(FileSystem fs, String cmd, String argv[], int cmdIndex, public void verify(FileSystem fs, String cmd, String argv[], int cmdIndex,
FsShell fsShell, int exitCode) throws Exception { FsShell fsShell, int exitCode) throws Exception {
int ec; int ec;
ec = FsShellPermissions.changePermissions(fs, cmd, argv, cmdIndex, fsShell); ec = FsShellPermissions.changePermissions(cmd, argv, cmdIndex, fsShell);
Assert.assertEquals(ec, exitCode); Assert.assertEquals(ec, exitCode);
} }