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 su...@apache.org on 2013/02/06 20:00:12 UTC
svn commit: r1443127 - in
/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common:
CHANGES.txt src/main/java/org/apache/hadoop/fs/shell/Delete.java
src/test/java/org/apache/hadoop/fs/TestFsShellReturnCode.java
Author: suresh
Date: Wed Feb 6 19:00:11 2013
New Revision: 1443127
URL: http://svn.apache.org/viewvc?rev=1443127&view=rev
Log:
HADOOP-9289. Merge 1443108 from trunk
Modified:
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Delete.java
hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellReturnCode.java
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1443127&r1=1443126&r2=1443127&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt Wed Feb 6 19:00:11 2013
@@ -301,6 +301,9 @@ Release 2.0.3-alpha - 2013-02-06
HADOOP-9278. Fix the file handle leak in HarMetaData.parseMetaData() in
HarFileSystem. (Chris Nauroth via szetszwo)
+ HADOOP-9289. FsShell rm -f fails for non-matching globs. (Daryn Sharp via
+ suresh)
+
Release 2.0.2-alpha - 2012-09-07
INCOMPATIBLE CHANGES
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Delete.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Delete.java?rev=1443127&r1=1443126&r2=1443127&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Delete.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Delete.java Wed Feb 6 19:00:11 2013
@@ -21,6 +21,7 @@ package org.apache.hadoop.fs.shell;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.LinkedList;
+import java.util.List;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
@@ -28,6 +29,7 @@ import org.apache.hadoop.fs.PathIOExcept
import org.apache.hadoop.fs.PathIsDirectoryException;
import org.apache.hadoop.fs.PathIsNotDirectoryException;
import org.apache.hadoop.fs.PathIsNotEmptyDirectoryException;
+import org.apache.hadoop.fs.PathNotFoundException;
import org.apache.hadoop.fs.Trash;
/**
@@ -72,6 +74,19 @@ class Delete {
}
@Override
+ protected List<PathData> expandArgument(String arg) throws IOException {
+ try {
+ return super.expandArgument(arg);
+ } catch (PathNotFoundException e) {
+ if (!ignoreFNF) {
+ throw e;
+ }
+ // prevent -f on a non-existent glob from failing
+ return new LinkedList<PathData>();
+ }
+ }
+
+ @Override
protected void processNonexistentPath(PathData item) throws IOException {
if (!ignoreFNF) super.processNonexistentPath(item);
}
Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellReturnCode.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellReturnCode.java?rev=1443127&r1=1443126&r2=1443127&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellReturnCode.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellReturnCode.java Wed Feb 6 19:00:11 2013
@@ -300,6 +300,46 @@ public class TestFsShellReturnCode {
}
@Test
+ public void testRmWithNonexistentGlob() throws Exception {
+ Configuration conf = new Configuration();
+ FsShell shell = new FsShell();
+ shell.setConf(conf);
+ final ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+ final PrintStream err = new PrintStream(bytes);
+ final PrintStream oldErr = System.err;
+ System.setErr(err);
+ final String results;
+ try {
+ int exit = shell.run(new String[]{"-rm", "nomatch*"});
+ assertEquals(1, exit);
+ results = bytes.toString();
+ assertTrue(results.contains("rm: `nomatch*': No such file or directory"));
+ } finally {
+ IOUtils.closeStream(err);
+ System.setErr(oldErr);
+ }
+ }
+
+ @Test
+ public void testRmForceWithNonexistentGlob() throws Exception {
+ Configuration conf = new Configuration();
+ FsShell shell = new FsShell();
+ shell.setConf(conf);
+ final ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+ final PrintStream err = new PrintStream(bytes);
+ final PrintStream oldErr = System.err;
+ System.setErr(err);
+ try {
+ int exit = shell.run(new String[]{"-rm", "-f", "nomatch*"});
+ assertEquals(0, exit);
+ assertTrue(bytes.toString().isEmpty());
+ } finally {
+ IOUtils.closeStream(err);
+ System.setErr(oldErr);
+ }
+ }
+
+ @Test
public void testInvalidDefaultFS() throws Exception {
// if default fs doesn't exist or is invalid, but the path provided in
// arguments is valid - fsshell should work