Skip to content

Commit 9dbb62e

Browse files
tigerquollJoshRosen
authored andcommitted
[SPARK-4787] Stop SparkContext if a DAGScheduler init error occurs
Author: Dale <[email protected]> Closes #3809 from tigerquoll/SPARK-4787 and squashes the following commits: 5661e01 [Dale] [SPARK-4787] Ensure that call to stop() doesn't lose the exception by using a finally block. 2172578 [Dale] [SPARK-4787] Stop context properly if an exception occurs during DAGScheduler initialization. (cherry picked from commit 3fddc94) Signed-off-by: Josh Rosen <[email protected]>
1 parent 93617dd commit 9dbb62e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

core/src/main/scala/org/apache/spark/SparkContext.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,13 @@ class SparkContext(config: SparkConf) extends Logging with ExecutorAllocationCli
326326
try {
327327
dagScheduler = new DAGScheduler(this)
328328
} catch {
329-
case e: Exception => throw
330-
new SparkException("DAGScheduler cannot be initialized due to %s".format(e.getMessage))
329+
case e: Exception => {
330+
try {
331+
stop()
332+
} finally {
333+
throw new SparkException("Error while constructing DAGScheduler", e)
334+
}
335+
}
331336
}
332337

333338
// start TaskScheduler after taskScheduler sets DAGScheduler reference in DAGScheduler's

0 commit comments

Comments
 (0)