HCAT-554 Loading data using HCatLoader() from a table on non default namenode fails.

git-svn-id: https://svn.apache.org/repos/asf/incubator/hcatalog/branches/branch-0.4@1421577 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/CHANGES.txt b/CHANGES.txt
index c2f1115..894db52 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -71,6 +71,8 @@
   OPTIMIZATIONS
 
   BUG FIXES
+  HCAT-554 Loading data using HCatLoader() from a table on non default namenode fails.(amalakar via avandana)
+
   HCAT-566 HCatTable doesn't report partition columns correctly. (mithun via traviscrawford)
 
   HCAT-562 HCatClient should allow for a table's message-topic-name to be queried for. (mithunr via avandana)
diff --git a/src/java/org/apache/hcatalog/mapreduce/HCatBaseInputFormat.java b/src/java/org/apache/hcatalog/mapreduce/HCatBaseInputFormat.java
index 0f97d33..bba8a45 100644
--- a/src/java/org/apache/hcatalog/mapreduce/HCatBaseInputFormat.java
+++ b/src/java/org/apache/hcatalog/mapreduce/HCatBaseInputFormat.java
@@ -48,7 +48,7 @@
 
 public abstract class HCatBaseInputFormat 
   extends InputFormat<WritableComparable, HCatRecord> {
-  
+
   /**
    * get the schema for the HCatRecord data returned by HCatInputFormat.
    * 
@@ -300,15 +300,14 @@
     pathStrings.add(location.substring(pathStart, length));
 
     Path[] paths = StringUtils.stringToPath(pathStrings.toArray(new String[0]));
-
-    FileSystem fs = FileSystem.get(jobConf);
-    Path path = paths[0].makeQualified(fs);
-    StringBuilder str = new StringBuilder(StringUtils.escapeString(
-                                                          path.toString()));
-    for(int i = 1; i < paths.length;i++) {
-      str.append(StringUtils.COMMA_STR);
-      path = paths[i].makeQualified(fs);
-      str.append(StringUtils.escapeString(path.toString()));
+    String separator = "";
+    StringBuilder str = new StringBuilder(); 
+    for (Path path : paths) {
+      FileSystem fs = path.getFileSystem(jobConf);
+      final String qualifiedPath = path.makeQualified(fs).toString();
+      str.append(separator)
+              .append(StringUtils.escapeString(qualifiedPath));
+      separator = StringUtils.COMMA_STR;
     }
 
     jobConf.set("mapred.input.dir", str.toString());