HCATALOG-199 HCatOutputCommitter::cleanupJob() fails : Unable to connect to metastore.


git-svn-id: https://svn.apache.org/repos/asf/incubator/hcatalog/branches/branch-0.2@1230843 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/CHANGES.txt b/CHANGES.txt
index 7f4d61f..4569c5b 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -81,6 +81,8 @@
   OPTIMIZATIONS
 
   BUG FIXES
+    HCAT-199. HCatOutputCommitter::cleanupJob() fails : Unable to connect to metastore. (mithun via khorgath)
+
     HCAT-136. Pig storer for export/import does maintain partition order (Krishna Kumar via hashutosh)
 
     HCAT-150. Updated documentation specifying the need to call HCatOutputFormat.setSchema() (chandec via toffer)
diff --git a/src/java/org/apache/hcatalog/mapreduce/HCatOutputFormat.java b/src/java/org/apache/hcatalog/mapreduce/HCatOutputFormat.java
index 0120286..80f8e43 100644
--- a/src/java/org/apache/hcatalog/mapreduce/HCatOutputFormat.java
+++ b/src/java/org/apache/hcatalog/mapreduce/HCatOutputFormat.java
@@ -436,9 +436,6 @@
             hiveConf.setBoolean(ConfVars.METASTORE_USE_THRIFT_SASL.varname, true);
             hiveConf.set(ConfVars.METASTORE_KERBEROS_PRINCIPAL.varname, kerberosPrincipal);
         }        
-        if(conf.get(HCatConstants.HCAT_KEY_TOKEN_SIGNATURE) != null) {
-          hiveConf.set("hive.metastore.token.signature", conf.get(HCatConstants.HCAT_KEY_TOKEN_SIGNATURE));
-        }
       } else {
         //Thrift url is null, copy the hive conf into the job conf and restore it
         //in the backend context
@@ -465,7 +462,11 @@
         }
 
       }
-      
+
+      if(conf.get(HCatConstants.HCAT_KEY_TOKEN_SIGNATURE) != null) {
+        hiveConf.set("hive.metastore.token.signature", conf.get(HCatConstants.HCAT_KEY_TOKEN_SIGNATURE));
+      }
+
       // figure out what the maximum number of partitions allowed is, so we can pass it on to our outputinfo
       if (HCatConstants.HCAT_IS_DYNAMIC_MAX_PTN_CHECK_ENABLED){
         maxDynamicPartitions = hiveConf.getIntVar(HiveConf.ConfVars.DYNAMICPARTITIONMAXPARTS);