Github user squito commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19698#discussion_r150622874
  
    --- Diff: core/src/main/scala/org/apache/spark/ui/jobs/JobPage.scala ---
    @@ -182,173 +185,183 @@ private[ui] class JobPage(parent: JobsTab) extends 
WebUIPage("job") {
       }
     
       def render(request: HttpServletRequest): Seq[Node] = {
    -    val listener = parent.jobProgresslistener
    +    // stripXSS is called first to remove suspicious characters used in 
XSS attacks
    +    val parameterId = UIUtils.stripXSS(request.getParameter("id"))
    +    require(parameterId != null && parameterId.nonEmpty, "Missing id 
parameter")
     
    -    listener.synchronized {
    -      // stripXSS is called first to remove suspicious characters used in 
XSS attacks
    -      val parameterId = UIUtils.stripXSS(request.getParameter("id"))
    -      require(parameterId != null && parameterId.nonEmpty, "Missing id 
parameter")
    -
    -      val jobId = parameterId.toInt
    -      val jobDataOption = listener.jobIdToData.get(jobId)
    -      if (jobDataOption.isEmpty) {
    -        val content =
    -          <div id="no-info">
    -            <p>No information to display for job {jobId}</p>
    -          </div>
    -        return UIUtils.headerSparkPage(
    -          s"Details for Job $jobId", content, parent)
    -      }
    -      val jobData = jobDataOption.get
    -      val isComplete = jobData.status != JobExecutionStatus.RUNNING
    -      val stages = jobData.stageIds.map { stageId =>
    -        // This could be empty if the JobProgressListener hasn't received 
information about the
    -        // stage or if the stage information has been garbage collected
    -        listener.stageIdToInfo.getOrElse(stageId,
    -          new StageInfo(stageId, 0, "Unknown", 0, Seq.empty, Seq.empty, 
"Unknown"))
    +    val jobId = parameterId.toInt
    +    val jobDataOption = Try(store.job(jobId)).toOption
    --- End diff --
    
    most places, you do an explicit try/catch, I assume because you only want 
to convert `NoSuchElementException` to `None`.  Does that concern not apply 
here?  also since you do that so much, maybe its worth a helper, so that you 
could use it like this?


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to