Index: metastore/src/test/org/apache/hadoop/hive/metastore/TestRemoteHiveMetaStore.java =================================================================== --- metastore/src/test/org/apache/hadoop/hive/metastore/TestRemoteHiveMetaStore.java (revision 1102355) +++ metastore/src/test/org/apache/hadoop/hive/metastore/TestRemoteHiveMetaStore.java (working copy) @@ -35,7 +35,12 @@ @Override public void run() { + try { HiveMetaStore.main(new String[] { METASTORE_PORT }); + } catch (Throwable e) { + e.printStackTrace(System.err); + assert false; + } } } Index: metastore/src/test/org/apache/hadoop/hive/metastore/TestMetaStoreEventListener.java =================================================================== --- metastore/src/test/org/apache/hadoop/hive/metastore/TestMetaStoreEventListener.java (revision 1102355) +++ metastore/src/test/org/apache/hadoop/hive/metastore/TestMetaStoreEventListener.java (working copy) @@ -53,7 +53,12 @@ @Override public void run() { - HiveMetaStore.main(new String[]{msPort}); + try { + HiveMetaStore.main(new String[]{msPort}); + } catch (Throwable e) { + e.printStackTrace(System.err); + assert false; + } } } Index: metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java =================================================================== --- metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java (revision 1102355) +++ metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java (working copy) @@ -539,7 +539,7 @@ if (ms != null) { ms.shutdown(); } - System.exit(0); + logInfo("Metastore shutdown complete."); } private void create_database_core(RawStore ms, final Database db) @@ -3149,7 +3149,7 @@ /** * @param args */ - public static void main(String[] args) { + public static void main(String[] args) throws Throwable{ int port = 9083; if (args.length > 0) { @@ -3158,9 +3158,10 @@ try { startMetaStore(port, ShimLoader.getHadoopThriftAuthBridge()); } catch (Throwable t) { + // Catch the exception, log it and rethrow it. HMSHandler.LOG - .error("Metastore Thrift Server threw an exception. Exiting..."); - System.exit(1); + .error("Metastore Thrift Server threw an exception...",t); + throw t; } } Index: metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java =================================================================== --- metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java (revision 1102355) +++ metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java (working copy) @@ -728,11 +728,12 @@ public static void startMetaStore(final int port, final HadoopThriftAuthBridge bridge) throws Exception { Thread thread = new Thread(new Runnable() { + @Override public void run() { try { HiveMetaStore.startMetaStore(port, bridge); } catch (Throwable e) { - System.exit(1); + LOG.error("Metastore Thrift Server threw an exception...",e); } } });