Author: cutting Date: Tue Mar 21 14:01:27 2006 New Revision: 387636 URL: http://svn.apache.org/viewcvs?rev=387636&view=rev Log: Fix for HADOOP-97. Improve error handling. Contributed by Konstantin Shvachko.
Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSShell.java Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSShell.java URL: http://svn.apache.org/viewcvs/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSShell.java?rev=387636&r1=387635&r2=387636&view=diff ============================================================================== --- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSShell.java (original) +++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSShell.java Tue Mar 21 14:01:27 2006 @@ -66,9 +66,8 @@ } void cat(String srcf) throws IOException { - FSDataInputStream in = null; + FSDataInputStream in = fs.open(new File(srcf)); try { - in = fs.open(new File(srcf)); DataInputStream din = new DataInputStream(new BufferedInputStream(in)); String line; while((line = din.readLine()) != null) { @@ -242,10 +241,10 @@ Configuration conf = new Configuration(); int i = 0; FileSystem fs = FileSystem.parseArgs(argv, i, conf); + String cmd = argv[i++]; try { DFSShell tc = new DFSShell(fs); - String cmd = argv[i++]; if ("-put".equals(cmd) || "-copyFromLocal".equals(cmd)) { tc.copyFromLocal(new File(argv[i++]), argv[i++]); } else if ("-moveFromLocal".equals(cmd)) { @@ -277,6 +276,9 @@ tc.report(); } System.exit(0); + } catch (IOException e ) { + System.err.println( cmd.substring(1) + ": " + e.getLocalizedMessage() ); + System.exit(-1); } finally { fs.close(); }