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

Commit 86fcdae

Browse files
committed
SPARK-1965 [WEBUI] Spark UI throws NPE on trying to load the app page for non-existent app
Don't throw NPE if appId is unknown. kayousterhout is this a decent enough band-aid for avoiding a full-blown NPE? it should just render empty content instead Author: Sean Owen <[email protected]> Closes apache#4777 from srowen/SPARK-1965 and squashes the following commits: 7e16590 [Sean Owen] Update app not found message cb878d6 [Sean Owen] Return basic "not found" page for unknown appId d8270da [Sean Owen] Don't throw NPE if appId is unknown
1 parent f91298e commit 86fcdae

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

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

Lines changed: 10 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,10 @@ 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+
val msg = <div class="row-fluid">No running application with ID {appId}</div>
65+
return UIUtils.basicSparkPage(msg, "Not Found")
66+
}
5867

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

0 commit comments

Comments
 (0)