override protected def afterExecute()

in thriftserver/server/src/main/scala/org/apache/livy/thriftserver/cli/ThreadPoolExecutorWithOomHook.scala [37:53]


  override protected def afterExecute(r: Runnable, t: Throwable): Unit = {
    super.afterExecute(r, t)
    if (t == null && r.isInstanceOf[Future[_]] ) {
      try {
        val future: Future[_] = r.asInstanceOf[Future[_]]
        if (future.isDone) {
          future.get
        }
      } catch {
        case _: InterruptedException => Thread.currentThread.interrupt()
        case _: OutOfMemoryError => oomHook.run()
        case _: Throwable => // Do nothing
      }
    } else if (t.isInstanceOf[OutOfMemoryError]) {
      oomHook.run()
    }
  }