Repository: spark
Updated Branches:
  refs/heads/master fe63e8229 -> 6c20f3529


[SPARK-6133] Make sc.stop() idempotent

Before we would get the following (benign) error if we called `sc.stop()` 
twice. This is because the listener bus would try to post the end event again 
even after it has already stopped. This happens occasionally when flaky tests 
fail, usually as a result of other sources of error. Either way we shouldn't be 
logging this error when it is not the cause of the failure.
```
ERROR LiveListenerBus: SparkListenerBus has already stopped! Dropping event 
SparkListenerApplicationEnd(1425348445682)
```

Author: Andrew Or <and...@databricks.com>

Closes #4871 from andrewor14/sc-stop and squashes the following commits:

a14afc5 [Andrew Or] Move code after code
915db16 [Andrew Or] Move code into code


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/6c20f352
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/6c20f352
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/6c20f352

Branch: refs/heads/master
Commit: 6c20f35290e220e4a659a0222d62575ff959d703
Parents: fe63e82
Author: Andrew Or <and...@databricks.com>
Authored: Tue Mar 3 15:09:57 2015 -0800
Committer: Andrew Or <and...@databricks.com>
Committed: Tue Mar 3 15:09:57 2015 -0800

----------------------------------------------------------------------
 core/src/main/scala/org/apache/spark/SparkContext.scala | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/6c20f352/core/src/main/scala/org/apache/spark/SparkContext.scala
----------------------------------------------------------------------
diff --git a/core/src/main/scala/org/apache/spark/SparkContext.scala 
b/core/src/main/scala/org/apache/spark/SparkContext.scala
index e231e83..1a0bee4 100644
--- a/core/src/main/scala/org/apache/spark/SparkContext.scala
+++ b/core/src/main/scala/org/apache/spark/SparkContext.scala
@@ -1392,10 +1392,10 @@ class SparkContext(config: SparkConf) extends Logging 
with ExecutorAllocationCli
   /** Shut down the SparkContext. */
   def stop() {
     SparkContext.SPARK_CONTEXT_CONSTRUCTOR_LOCK.synchronized {
-      postApplicationEnd()
-      ui.foreach(_.stop())
       if (!stopped) {
         stopped = true
+        postApplicationEnd()
+        ui.foreach(_.stop())
         env.metricsSystem.report()
         metadataCleaner.cancel()
         cleaner.foreach(_.stop())


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to