Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

Commit d8270da

Browse files
committed
Don't throw NPE if appId is unknown
1 parent 7d8e6a2 commit d8270da

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

core/src/main/scala/org/apache/spark/deploy/master/ui/ApplicationPage.scala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import scala.xml.Node
2424

2525
import akka.pattern.ask
2626
import org.json4s.JValue
27+
import org.json4s.JsonAST.JNothing
2728

2829
import org.apache.spark.deploy.{ExecutorState, JsonProtocol}
2930
import org.apache.spark.deploy.DeployMessages.{MasterStateResponse, RequestMasterState}
@@ -44,7 +45,11 @@ private[spark] class ApplicationPage(parent: MasterWebUI) extends WebUIPage("app
4445
val app = state.activeApps.find(_.id == appId).getOrElse({
4546
state.completedApps.find(_.id == appId).getOrElse(null)
4647
})
47-
JsonProtocol.writeApplicationInfo(app)
48+
if (app == null) {
49+
JNothing
50+
} else {
51+
JsonProtocol.writeApplicationInfo(app)
52+
}
4853
}
4954

5055
/** Executor details for a particular application */
@@ -55,6 +60,9 @@ private[spark] class ApplicationPage(parent: MasterWebUI) extends WebUIPage("app
5560
val app = state.activeApps.find(_.id == appId).getOrElse({
5661
state.completedApps.find(_.id == appId).getOrElse(null)
5762
})
63+
if (app == null) {
64+
return Seq[Node]()
65+
}
5866

5967
val executorHeaders = Seq("ExecutorID", "Worker", "Cores", "Memory", "State", "Logs")
6068
val allExecutors = (app.executors.values ++ app.removedExecutors).toSet.toSeq

0 commit comments

Comments
 (0)