Index: beeline/src/java/org/apache/hive/beeline/BeeLine.java =================================================================== --- beeline/src/java/org/apache/hive/beeline/BeeLine.java (revision 1568587) +++ beeline/src/java/org/apache/hive/beeline/BeeLine.java (working copy) @@ -620,7 +620,8 @@ // load the options first, so we can override on the command line getOpts().load(); } catch (Exception e) { - // nothing + // Cannot load opts.. + handleException(e); } if (!(initArgs(args))) { @@ -1460,7 +1461,12 @@ // now instantiate and initialize it driverClasses.add(c.newInstance()); + } catch (ClassNotFoundException ignore) { + // if no such class it is OK } catch (Throwable t) { + // other exceptions, such as InvocationTargetException, are + // unexpected and should be logged. + error(t); } } info("scan complete in " @@ -1522,17 +1528,30 @@ try { // load and initialize Class.forName(name); + } catch (ClassNotFoundException ignore) { + // if no such class it is OK } catch (Exception e) { + // other exceptions, are + // unexpected and should be logged. + error(e); } driverClasses.add(c.newInstance()); } } + } catch (ClassNotFoundException ignore) { + // if no such class it is OK } catch (Throwable t) { + // other exceptions, such as InvocationTargetException, are + // unexpected and should be logged. + error(t); } } } progress(total, total); } catch (Exception e) { + // This shouldn't happen, so something must be wrong if + // we reach here. + error(e); } } @@ -1601,6 +1620,7 @@ try { stmnt.close(); } catch (Exception e) { + info("Unexpected exception during stmnt.close(): " + e); } } } catch (Exception e) { Index: beeline/src/java/org/apache/hive/beeline/Commands.java =================================================================== --- beeline/src/java/org/apache/hive/beeline/Commands.java (revision 1568587) +++ beeline/src/java/org/apache/hive/beeline/Commands.java (working copy) @@ -239,6 +239,8 @@ try { rs.close(); } catch (Exception e) { + // exception when closing the ResultSet + beeLine.error(e); } } // run as a batch @@ -356,6 +358,7 @@ try { beeLine.getOpts().save(); } catch (Exception saveException) { + beeLine.error(saveException); } } return success; Index: beeline/src/java/org/apache/hive/beeline/DatabaseConnection.java =================================================================== --- beeline/src/java/org/apache/hive/beeline/DatabaseConnection.java (revision 1568587) +++ beeline/src/java/org/apache/hive/beeline/DatabaseConnection.java (working copy) @@ -125,6 +125,7 @@ try { foundDriver = DriverManager.getDriver(getUrl()) != null; } catch (Exception e) { + beeLine.error(e); } try { Index: hcatalog/core/src/main/java/org/apache/hcatalog/cli/HCatCli.java =================================================================== --- hcatalog/core/src/main/java/org/apache/hcatalog/cli/HCatCli.java (revision 1568587) +++ hcatalog/core/src/main/java/org/apache/hcatalog/cli/HCatCli.java (working copy) @@ -60,12 +60,6 @@ @SuppressWarnings("static-access") public static void main(String[] args) { - try { - LogUtils.initHiveLog4j(); - } catch (LogInitializationException e) { - - } - CliSessionState ss = new CliSessionState(new HiveConf(SessionState.class)); ss.in = System.in; try { @@ -74,7 +68,13 @@ } catch (UnsupportedEncodingException e) { System.exit(1); } - + + try { + LogUtils.initHiveLog4j(); + } catch (LogInitializationException e) { + ss.err.println("Failed to initialize Log4j, exception: " + e); + } + HiveConf conf = ss.getConf(); HiveConf.setVar(conf, ConfVars.SEMANTIC_ANALYZER_HOOK, HCatSemanticAnalyzer.class.getName()); Index: hcatalog/core/src/main/java/org/apache/hive/hcatalog/cli/HCatCli.java =================================================================== --- hcatalog/core/src/main/java/org/apache/hive/hcatalog/cli/HCatCli.java (revision 1568587) +++ hcatalog/core/src/main/java/org/apache/hive/hcatalog/cli/HCatCli.java (working copy) @@ -57,12 +57,7 @@ @SuppressWarnings("static-access") public static void main(String[] args) { - try { - LogUtils.initHiveLog4j(); - } catch (LogInitializationException e) { - } - CliSessionState ss = new CliSessionState(new HiveConf(SessionState.class)); ss.in = System.in; try { @@ -72,6 +67,12 @@ System.exit(1); } + try { + LogUtils.initHiveLog4j(); + } catch (LogInitializationException e) { + ss.err.println("Failed to initialize Log4j, exception: " + e); + } + HiveConf conf = ss.getConf(); HiveConf.setVar(conf, ConfVars.SEMANTIC_ANALYZER_HOOK, HCatSemanticAnalyzer.class.getName()); Index: hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/tool/JobState.java =================================================================== --- hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/tool/JobState.java (revision 1568587) +++ hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/tool/JobState.java (working copy) @@ -115,8 +115,7 @@ /** * The percent complete of a job */ - public String getPercentComplete() - throws IOException { + public String getPercentComplete() { return getField("percentComplete"); } @@ -133,11 +132,8 @@ */ public void addChild(String jobid) throws IOException { String jobids = ""; - try { - jobids = getField("children"); - } catch (Exception e) { - // There are none or they're not readable. - } + jobids = getField("children"); + if (jobids==null) { jobids = ""; } @@ -201,8 +197,7 @@ /** * The user who started this job. */ - public String getUser() - throws IOException { + public String getUser() { return getField("user"); } @@ -228,8 +223,7 @@ /** * The url callback */ - public String getCallback() - throws IOException { + public String getCallback() { return getField("callback"); } @@ -241,8 +235,7 @@ /** * The status of a job once it is completed. */ - public String getCompleteStatus() - throws IOException { + public String getCompleteStatus() { return getField("completed"); } @@ -298,8 +291,7 @@ } } - public String getField(String name) - throws IOException { + public String getField(String name) { return storage.getField(type, id, name); } Index: hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/tool/ZooKeeperCleanup.java =================================================================== --- hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/tool/ZooKeeperCleanup.java (revision 1568587) +++ hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/tool/ZooKeeperCleanup.java (working copy) @@ -116,7 +116,7 @@ try { zk.close(); } catch (InterruptedException e) { - // We're trying to exit anyway, just ignore. + LOG.warn("Interrupted when closing down, ", e); } } } Index: hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/tool/ZooKeeperStorage.java =================================================================== --- hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/tool/ZooKeeperStorage.java (revision 1568587) +++ hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/tool/ZooKeeperStorage.java (working copy) @@ -127,6 +127,7 @@ Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); wasCreated = true; } catch (KeeperException.NodeExistsException e) { + LOG.warn("Zookeeper node already exists: " + id); } } if (wasCreated) { Index: hwi/src/java/org/apache/hadoop/hive/hwi/HWISessionItem.java =================================================================== --- hwi/src/java/org/apache/hadoop/hive/hwi/HWISessionItem.java (revision 1568587) +++ hwi/src/java/org/apache/hadoop/hive/hwi/HWISessionItem.java (working copy) @@ -122,7 +122,8 @@ if (status != WebSessionItemStatus.READY) { try { runnable.wait(); - } catch (Exception ex) { + } catch (InterruptedException ex) { + l4j.warn("Interrupted: ", ex); } } } Index: jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveConnection.java =================================================================== --- jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveConnection.java (revision 1568587) +++ jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveConnection.java (working copy) @@ -18,6 +18,8 @@ package org.apache.hadoop.hive.jdbc; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.apache.hadoop.hive.conf.HiveConf; import org.apache.hadoop.hive.metastore.api.MetaException; import org.apache.hadoop.hive.service.HiveClient; @@ -29,8 +31,8 @@ import org.apache.thrift.transport.TSocket; import org.apache.thrift.transport.TTransport; import org.apache.thrift.transport.TTransportException; + import java.util.concurrent.Executor; - import java.sql.Array; import java.sql.Blob; import java.sql.CallableStatement; @@ -54,6 +56,8 @@ * */ public class HiveConnection implements java.sql.Connection { + public static final Log LOG = LogFactory.getLog(HiveConnection.class); + private TTransport transport; private HiveInterface client; private boolean isClosed = true; @@ -106,7 +110,8 @@ String host = hostport[0]; try { port = Integer.parseInt(hostport[1]); - } catch (Exception e) { + } catch (NumberFormatException e) { + LOG.warn("Illegal format of hostport: " + hostport[1]); } transport = new TSocket(host, port); TProtocol protocol = new TBinaryProtocol(transport); Index: ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java (revision 1568587) +++ ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java (working copy) @@ -390,6 +390,7 @@ children.toArray(new String[children.size()])); } } catch (IOException e) { + LOG.warn("Caught exception: ", e); } } Index: ql/src/java/org/apache/hadoop/hive/ql/exec/mr/ExecDriver.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/exec/mr/ExecDriver.java (revision 1568587) +++ ql/src/java/org/apache/hadoop/hive/ql/exec/mr/ExecDriver.java (working copy) @@ -454,6 +454,8 @@ jobID = rj.getID().toString(); } } catch (Exception e) { + String mesg = "Caught exception during clean-up after job submission"; + console.printError(mesg, "\n" + org.apache.hadoop.util.StringUtils.stringifyException(e)); } } Index: ql/src/java/org/apache/hadoop/hive/ql/exec/mr/HadoopJobExecHelper.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/exec/mr/HadoopJobExecHelper.java (revision 1568587) +++ ql/src/java/org/apache/hadoop/hive/ql/exec/mr/HadoopJobExecHelper.java (working copy) @@ -490,6 +490,7 @@ try { exitVal = runningJob.waitFor(); //TODO: poll periodically } catch (InterruptedException e) { + console.printInfo("Interrupted when waiting for runningJob." + e); } if (exitVal != 0) { Index: ql/src/java/org/apache/hadoop/hive/ql/history/HiveHistoryUtil.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/history/HiveHistoryUtil.java (revision 1568587) +++ ql/src/java/org/apache/hadoop/hive/ql/history/HiveHistoryUtil.java (working copy) @@ -60,6 +60,8 @@ try { reader.close(); } catch (IOException ex) { + // Exception during close... Something wrong.. + throw ex; } } } Index: ql/src/java/org/apache/hadoop/hive/ql/processors/CompileProcessor.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/processors/CompileProcessor.java (revision 1568587) +++ ql/src/java/org/apache/hadoop/hive/ql/processors/CompileProcessor.java (working copy) @@ -228,6 +228,7 @@ try { out.close(); } catch (IOException WhatCanYouDo) { + LOG.warn("Caught exception when closing outputstream", WhatCanYouDo); } } }