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

    https://github.com/apache/spark/pull/2760#discussion_r18859471
  
    --- Diff: core/src/main/scala/org/apache/spark/FutureAction.scala ---
    @@ -271,3 +274,55 @@ class ComplexFutureAction[T] extends FutureAction[T] {
       def jobIds = jobs
     
     }
    +
    +private[spark]
    +class JavaFutureActionWrapper[S, T](futureAction: FutureAction[S], 
converter: S => T)
    +  extends JavaFutureAction[T] {
    +
    +  import scala.collection.JavaConverters._
    +
    +  override def isCancelled: Boolean = futureAction.isCancelled
    +
    +  override def isDone: Boolean = {
    +    // According to java.util.Future's Javadoc, this returns True if the 
task was completed,
    +    // whether that completion was due to succesful execution, an 
exception, or a cancellation.
    +    futureAction.isCancelled || futureAction.isCompleted
    +  }
    +
    +  override def jobIds(): java.util.List[java.lang.Integer] = {
    +    new java.util.ArrayList(futureAction.jobIds.map(x => new 
Integer(x)).asJava)
    +  }
    +
    +  private def getImpl(timeout: Duration): T = {
    +    // This will throw TimeoutException on timeout:
    +    Await.ready(futureAction, timeout)
    +    futureAction.value.get match {
    +      case scala.util.Success(value) => converter(value)
    +      case Failure(exception) =>
    +        if (isCancelled) {
    +          throw new CancellationException("Job cancelled: 
${exception.message}");
    --- End diff --
    
    Ah, but I can do this:
    
    ```scala
    val ce =  new CancellationException("Job cancelled")
    ce.initCause(exception)
    throw ce
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to