Skip to content

Commit c4fbcae

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 b633559 commit c4fbcae

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
@@ -310,8 +310,13 @@ class SparkContext(config: SparkConf) extends Logging {
310310
try {
311311
dagScheduler = new DAGScheduler(this)
312312
} catch {
313-
case e: Exception => throw
314-
new SparkException("DAGScheduler cannot be initialized due to %s".format(e.getMessage))
313+
case e: Exception => {
314+
try {
315+
stop()
316+
} finally {
317+
throw new SparkException("Error while constructing DAGScheduler", e)
318+
}
319+
}
315320
}
316321

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

0 commit comments

Comments
 (0)