aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/src/main/scala/org/apache/spark/SparkContext.scala18
1 files changed, 17 insertions, 1 deletions
diff --git a/core/src/main/scala/org/apache/spark/SparkContext.scala b/core/src/main/scala/org/apache/spark/SparkContext.scala
index 43a241686f..4bbd0b038c 100644
--- a/core/src/main/scala/org/apache/spark/SparkContext.scala
+++ b/core/src/main/scala/org/apache/spark/SparkContext.scala
@@ -96,7 +96,23 @@ class SparkContext(config: SparkConf) extends Logging with ExecutorAllocationCli
private def assertNotStopped(): Unit = {
if (stopped.get()) {
- throw new IllegalStateException("Cannot call methods on a stopped SparkContext")
+ val activeContext = SparkContext.activeContext.get()
+ val activeCreationSite =
+ if (activeContext == null) {
+ "(No active SparkContext.)"
+ } else {
+ activeContext.creationSite.longForm
+ }
+ throw new IllegalStateException(
+ s"""Cannot call methods on a stopped SparkContext.
+ |This stopped SparkContext was created at:
+ |
+ |${creationSite.longForm}
+ |
+ |The currently active SparkContext was created at:
+ |
+ |$activeCreationSite
+ """.stripMargin)
}
}