diff --git a/plugins/jobtype/src/azkaban/jobtype/HadoopSecureHiveWrapper.java b/plugins/jobtype/src/azkaban/jobtype/HadoopSecureHiveWrapper.java index 3dabc643..5e2d6ad7 100644 --- a/plugins/jobtype/src/azkaban/jobtype/HadoopSecureHiveWrapper.java +++ b/plugins/jobtype/src/azkaban/jobtype/HadoopSecureHiveWrapper.java @@ -157,11 +157,22 @@ public static void runHive(String[] args) throws Exception { cli.setHiveVariables(getHiveVarMap(args)); } - int returnCode = cli.processFile(hiveScript); - if (returnCode != 0) { - logger.warn("Got exception " + returnCode + " from line: " + hiveScript); - throw new HiveQueryExecutionException(returnCode, hiveScript); + int returnCode = 0; + try { + returnCode = cli.processFile(hiveScript); + } catch (Exception ex) { + logger.error("Error processing file: ", ex); + } finally { + logger.info("Closing session state."); + if (ss != null) + ss.close(); } + + if (returnCode != 0) { + logger.warn("Got exception " + returnCode + " from line: " + hiveScript); + throw new HiveQueryExecutionException(returnCode, hiveScript); + } + } /**