diff --git metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java index 2ccdaab..8d8bbad 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java @@ -523,7 +523,7 @@ public class HiveMetaStore extends ThriftHiveMetastore { if (ms != null) { ms.shutdown(); } - System.exit(0); + logInfo("Metastore shutdown complete."); } private void create_database_core(RawStore ms, final Database db) @@ -3116,7 +3116,7 @@ public class HiveMetaStore extends ThriftHiveMetastore { /** * @param args */ - public static void main(String[] args) { + public static void main(String[] args) throws Throwable{ int port = 9083; if (args.length > 0) { @@ -3125,9 +3125,10 @@ public class HiveMetaStore extends ThriftHiveMetastore { 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; } } diff --git metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java index f917878..109685b 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java @@ -727,11 +727,12 @@ public class MetaStoreUtils { 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); } } }); diff --git metastore/src/test/org/apache/hadoop/hive/metastore/TestRemoteHiveMetaStore.java metastore/src/test/org/apache/hadoop/hive/metastore/TestRemoteHiveMetaStore.java index 60a8e8a..3f9e984 100644 --- metastore/src/test/org/apache/hadoop/hive/metastore/TestRemoteHiveMetaStore.java +++ metastore/src/test/org/apache/hadoop/hive/metastore/TestRemoteHiveMetaStore.java @@ -35,7 +35,12 @@ public class TestRemoteHiveMetaStore extends TestHiveMetaStore { @Override public void run() { + try { HiveMetaStore.main(new String[] { METASTORE_PORT }); + } catch (Throwable e) { + e.printStackTrace(System.err); + assert false; + } } }