Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import java.util.NoSuchElementException
import java.util.zip.ZipOutputStream
import javax.servlet.http.{HttpServlet, HttpServletRequest, HttpServletResponse}

import scala.util.control.NonFatal

import com.google.common.cache._
import org.eclipse.jetty.servlet.{ServletContextHandler, ServletHolder}

Expand Down Expand Up @@ -115,7 +117,17 @@ class HistoryServer(
}

Copy link
Contributor

Choose a reason for hiding this comment

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

is it a better fix to do appCache.getIfPresent here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

appCache.getIfPresent returns null if there is no cached value for the appKey. But appCache.get will try to obtain that value from a CacheLoader, cache it and return it. So I think we still need use appCache.get here and handle the exception.

def getSparkUI(appKey: String): Option[SparkUI] = {
Option(appCache.get(appKey))
try {
val ui = appCache.get(appKey)
Some(ui)
} catch {
case NonFatal(e) => e.getCause() match {
case nsee: NoSuchElementException =>
None

case cause: Exception => throw cause
}
}
}

initialize()
Expand Down Expand Up @@ -195,7 +207,7 @@ class HistoryServer(
appCache.get(appId + attemptId.map { id => s"/$id" }.getOrElse(""))
true
} catch {
case e: Exception => e.getCause() match {
case NonFatal(e) => e.getCause() match {
case nsee: NoSuchElementException =>
false

Expand Down