Author: rangadi
Date: Mon Feb 11 22:42:18 2008
New Revision: 620708
URL: http://svn.apache.org/viewvc?rev=620708&view=rev
Log:
HADOOP-2193. 'fs -rm' and 'fs -rmr' show error message when the target
file does not exist. (Mahadev Konar via rangadi)
Modified:
hadoop/core/trunk/CHANGES.txt
hadoop/core/trunk/src/java/org/apache/hadoop/fs/FsShell.java
hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestDFSShell.java
Modified: hadoop/core/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=620708&r1=620707&r2=620708&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Mon Feb 11 22:42:18 2008
@@ -15,6 +15,9 @@
BUG FIXES
+ HADOOP-2193. 'fs -rm' and 'fs -rmr' show error message when the target
+ file does not exist. (Mahadev Konar via rangadi)
+
HADOOP-2738 Text is not subclassable because set(Text) and
compareTo(Object)
access the other instance's private members directly.
Modified: hadoop/core/trunk/src/java/org/apache/hadoop/fs/FsShell.java
URL:
http://svn.apache.org/viewvc/hadoop/core/trunk/src/java/org/apache/hadoop/fs/FsShell.java?rev=620708&r1=620707&r2=620708&view=diff
==============================================================================
--- hadoop/core/trunk/src/java/org/apache/hadoop/fs/FsShell.java (original)
+++ hadoop/core/trunk/src/java/org/apache/hadoop/fs/FsShell.java Mon Feb 11
22:42:18 2008
@@ -18,6 +18,7 @@
package org.apache.hadoop.fs;
import java.io.File;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
@@ -981,6 +982,10 @@
if (srcFs.delete(src)) {
System.out.println("Deleted " + src);
} else {
+ if (!srcFs.exists(src)) {
+ throw new FileNotFoundException("cannot remove "
+ + src + ": No such file or directory.");
+ }
throw new IOException("Delete failed " + src);
}
}
Modified: hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestDFSShell.java
URL:
http://svn.apache.org/viewvc/hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestDFSShell.java?rev=620708&r1=620707&r2=620708&view=diff
==============================================================================
--- hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestDFSShell.java
(original)
+++ hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestDFSShell.java Mon Feb
11 22:42:18 2008
@@ -176,7 +176,7 @@
/** check if we have any exceptions in cat command output */
- public void testCatException() throws Exception {
+ public void testErrOutPut() throws Exception {
Configuration conf = new Configuration();
MiniDFSCluster cluster = null;
PrintStream bak = null;
@@ -195,6 +195,24 @@
String returned = out.toString();
assertTrue("cat does not print exceptions ",
(returned.lastIndexOf("Exception") == -1));
+ out.reset();
+ argv[0] = "-rm";
+ argv[1] = root.toString();
+ FsShell shell = new FsShell();
+ shell.setConf(conf);
+ ret = ToolRunner.run(shell, argv);
+ assertTrue(" -rm returned -1 ", 0>=ret);
+ returned = out.toString();
+ out.reset();
+ assertTrue("rm prints reasonable error ",
+ (returned.lastIndexOf("No such file or directory") != -1));
+ argv[0] = "-rmr";
+ argv[1] = root.toString();
+ ret = ToolRunner.run(shell, argv);
+ assertTrue(" -rmr returned -1", 0>=ret);
+ returned = out.toString();
+ assertTrue("rmr prints reasonable error ",
+ (returned.lastIndexOf("No such file or directory") != -1));
} finally {
if (bak != null) {
System.setErr(bak);