From f590178d7a06221a93286757c68b23919bee9f03 Mon Sep 17 00:00:00 2001 From: tedyu Date: Wed, 16 Dec 2015 19:02:12 -0800 Subject: [SPARK-12365][CORE] Use ShutdownHookManager where Runtime.getRuntime.addShutdownHook() is called SPARK-9886 fixed ExternalBlockStore.scala This PR fixes the remaining references to Runtime.getRuntime.addShutdownHook() Author: tedyu Closes #10325 from ted-yu/master. --- .../sql/hive/thriftserver/SparkSQLCLIDriver.scala | 24 ++++++++++------------ 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'sql') diff --git a/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLCLIDriver.scala b/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLCLIDriver.scala index 03bb2c2225..8e7aa75bc3 100644 --- a/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLCLIDriver.scala +++ b/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLCLIDriver.scala @@ -195,20 +195,18 @@ private[hive] object SparkSQLCLIDriver extends Logging { } // add shutdown hook to flush the history to history file - Runtime.getRuntime.addShutdownHook(new Thread(new Runnable() { - override def run() = { - reader.getHistory match { - case h: FileHistory => - try { - h.flush() - } catch { - case e: IOException => - logWarning("WARNING: Failed to write command history file: " + e.getMessage) - } - case _ => - } + ShutdownHookManager.addShutdownHook { () => + reader.getHistory match { + case h: FileHistory => + try { + h.flush() + } catch { + case e: IOException => + logWarning("WARNING: Failed to write command history file: " + e.getMessage) + } + case _ => } - })) + } // TODO: missing /* -- cgit v1.2.3