Skip to content
25 changes: 19 additions & 6 deletions core/src/main/scala/org/apache/spark/ui/jobs/StagePage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package org.apache.spark.ui.jobs

import java.net.URLEncoder
import java.util.Date
import java.util.{Date, NoSuchElementException}
import java.util.concurrent.TimeUnit
import javax.servlet.http.HttpServletRequest

Expand Down Expand Up @@ -105,16 +105,29 @@ private[ui] class StagePage(parent: StagesTab, store: AppStatusStore) extends We
val stageAttemptId = parameterAttempt.toInt

val stageHeader = s"Details for Stage $stageId (Attempt $stageAttemptId)"
val stageDataWrapper = parent.store.stageAttempt(stageId, stageAttemptId, details = false)
val stageData = parent.store
.asOption(stageDataWrapper.info)
.getOrElse {
var stageDataWrapper: StageDataWrapper = null
try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could use options here instead of try and null checks to make this cleaner

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks!

stageDataWrapper = parent.store.stageAttempt(stageId, stageAttemptId, details = false)
} catch {
case e: NoSuchElementException => e.getMessage
}
var stageData: StageData = null
if (stageDataWrapper != null) {
stageData = parent.store
.asOption(stageDataWrapper.info)
.get
} else {
stageData = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code branch is unreachable.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is unreachable by the IDE but during runtime, the code does work, I have confirmed that.

val content =
<div id="no-info">
<p>No information to display for Stage {stageId} (Attempt {stageAttemptId})</p>
<p>No information to display for Stage
{stageId}
(Attempt
{stageAttemptId})</p>
</div>
return UIUtils.headerSparkPage(request, stageHeader, content, parent)
}
}

val stageJobIds = stageDataWrapper.jobIds.toSeq

Expand Down