From 151c1a79526ef6260971c5a39befae86ffd3ec39 Mon Sep 17 00:00:00 2001 From: Boris Shkolnik Date: Tue, 22 Mar 2011 23:54:29 +0000 Subject: [PATCH] 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 --- CHANGES.txt | 3 +++ src/java/org/apache/hadoop/fs/FsShell.java | 4 +-- .../apache/hadoop/fs/FsShellPermissions.java | 26 ++++++++++--------- .../hadoop/fs/TestFsShellReturnCode.java | 2 +- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index a63ed66a0c1..a6a6a8d47eb 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -121,6 +121,9 @@ Trunk (unreleased changes) HADOOP-6912. Guard against NPE when calling UGI.isLoginKeytabBased(). (Kan Zhang via jitendra) + HADOOP-7204. remove local unused fs variable from CmdHandler + and FsShellPermissions.changePermissions (boryas) + Release 0.22.0 - Unreleased INCOMPATIBLE CHANGES diff --git a/src/java/org/apache/hadoop/fs/FsShell.java b/src/java/org/apache/hadoop/fs/FsShell.java index a83703db4c9..85e74dc5737 100644 --- a/src/java/org/apache/hadoop/fs/FsShell.java +++ b/src/java/org/apache/hadoop/fs/FsShell.java @@ -1263,7 +1263,7 @@ public class FsShell extends Configured implements Tool { boolean okToContinue() { return okToContinue; } String getName() { return cmdName; } - protected CmdHandler(String cmdName, FileSystem fs) { + protected CmdHandler(String cmdName) { this.cmdName = cmdName; } @@ -1911,7 +1911,7 @@ public class FsShell extends Configured implements Tool { } else if ("-chmod".equals(cmd) || "-chown".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)) { if (i < argv.length) { exitCode = doall(cmd, argv, i); diff --git a/src/java/org/apache/hadoop/fs/FsShellPermissions.java b/src/java/org/apache/hadoop/fs/FsShellPermissions.java index 6b5e89254a7..3dec4a3eba0 100644 --- a/src/java/org/apache/hadoop/fs/FsShellPermissions.java +++ b/src/java/org/apache/hadoop/fs/FsShellPermissions.java @@ -55,8 +55,8 @@ class FsShellPermissions { private static class ChmodHandler extends CmdHandler { - ChmodHandler(FileSystem fs, String modeStr) throws IOException { - super("chmod", fs); + ChmodHandler(String modeStr) throws IOException { + super("chmod"); try { pp = new ChmodParser(modeStr); } catch(IllegalArgumentException iea) { @@ -103,12 +103,14 @@ class FsShellPermissions { protected String owner = null; protected String group = null; - protected ChownHandler(String cmd, FileSystem fs) { //for chgrp - super(cmd, fs); + protected ChownHandler(String cmd) { //for chgrp + super(cmd); } - ChownHandler(FileSystem fs, String ownerStr) throws IOException { - super("chown", fs); + ChownHandler(String cmd, String ownerStr) throws IOException { + super(cmd); + if(!cmd.equals("chown")) + return; Matcher matcher = chownPattern.matcher(ownerStr); if (!matcher.matches()) { throw new IOException("'" + ownerStr + "' does not match " + @@ -149,8 +151,8 @@ class FsShellPermissions { /*========== chgrp ==========*/ private static class ChgrpHandler extends ChownHandler { - ChgrpHandler(FileSystem fs, String groupStr) throws IOException { - super("chgrp", fs); + ChgrpHandler(String groupStr) throws IOException { + super("chgrp"); Matcher matcher = chgrpPattern.matcher(groupStr); 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) throws IOException { CmdHandler handler = null; @@ -178,11 +180,11 @@ class FsShellPermissions { } if (cmd.equals("-chmod")) { - handler = new ChmodHandler(fs, argv[startIndex++]); + handler = new ChmodHandler(argv[startIndex++]); } else if (cmd.equals("-chown")) { - handler = new ChownHandler(fs, argv[startIndex++]); + handler = new ChownHandler(argv[startIndex++]); } else if (cmd.equals("-chgrp")) { - handler = new ChgrpHandler(fs, argv[startIndex++]); + handler = new ChgrpHandler(argv[startIndex++]); } return shell.runCmdHandler(handler, argv, startIndex, recursive); diff --git a/src/test/core/org/apache/hadoop/fs/TestFsShellReturnCode.java b/src/test/core/org/apache/hadoop/fs/TestFsShellReturnCode.java index fa29955e5f6..8684a67c01f 100644 --- a/src/test/core/org/apache/hadoop/fs/TestFsShellReturnCode.java +++ b/src/test/core/org/apache/hadoop/fs/TestFsShellReturnCode.java @@ -51,7 +51,7 @@ public class TestFsShellReturnCode { public void verify(FileSystem fs, String cmd, String argv[], int cmdIndex, FsShell fsShell, int exitCode) throws Exception { int ec; - ec = FsShellPermissions.changePermissions(fs, cmd, argv, cmdIndex, fsShell); + ec = FsShellPermissions.changePermissions(cmd, argv, cmdIndex, fsShell); Assert.assertEquals(ec, exitCode); }