From d3dccec7afd96bcff1c0b22be9c3074a72a5e5dc Mon Sep 17 00:00:00 2001 From: Jonathan Hsieh Date: Tue, 3 Jul 2012 21:22:55 +0000 Subject: [PATCH] HBASE-6306 TestFSUtils fails against hadoop 2.0 git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1356954 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/hadoop/hbase/util/FSUtils.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java index e12d26944ab..528cf09b477 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java @@ -267,7 +267,14 @@ public abstract class FSUtils { public static String getVersion(FileSystem fs, Path rootdir) throws IOException, DeserializationException { Path versionFile = new Path(rootdir, HConstants.VERSION_FILE_NAME); - FileStatus [] status = fs.listStatus(versionFile); + FileStatus[] status = null; + try { + // hadoop 2.0 throws FNFE if directory does not exist. + // hadoop 1.0 returns null if directory does not exist. + status = fs.listStatus(versionFile); + } catch (FileNotFoundException fnfe) { + return null; + } if (status == null || status.length == 0) return null; String version = null; byte [] content = new byte [(int)status[0].getLen()];