diff options
Diffstat (limited to 'core/src/main/scala/org/apache/spark/TaskContext.scala')
-rw-r--r-- | core/src/main/scala/org/apache/spark/TaskContext.scala | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/core/src/main/scala/org/apache/spark/TaskContext.scala b/core/src/main/scala/org/apache/spark/TaskContext.scala index 0b87cd503d..742828a227 100644 --- a/core/src/main/scala/org/apache/spark/TaskContext.scala +++ b/core/src/main/scala/org/apache/spark/TaskContext.scala @@ -103,6 +103,10 @@ abstract class TaskContext extends Serializable { @deprecated("Local execution was removed, so this always returns false", "2.0.0") def isRunningLocally(): Boolean + // TODO(josh): this used to be an overload of addTaskCompletionListener(), but the overload + // became ambiguous under Scala 2.12. For now, I'm renaming this in order to get the code to + // compile, but we need to figure out a long-term solution which maintains at least source + // compatibility (and probably binary compatibility) for Java callers. /** * Adds a (Java friendly) listener to be executed on task completion. * This will be called in all situations - success, failure, or cancellation. Adding a listener @@ -112,7 +116,7 @@ abstract class TaskContext extends Serializable { * * Exceptions thrown by the listener will result in failure of the task. */ - def addTaskCompletionListener(listener: TaskCompletionListener): TaskContext + def addJavaFriendlyTaskCompletionListener(listener: TaskCompletionListener): TaskContext /** * Adds a listener in the form of a Scala closure to be executed on task completion. @@ -124,23 +128,27 @@ abstract class TaskContext extends Serializable { * Exceptions thrown by the listener will result in failure of the task. */ def addTaskCompletionListener(f: (TaskContext) => Unit): TaskContext = { - addTaskCompletionListener(new TaskCompletionListener { + addJavaFriendlyTaskCompletionListener(new TaskCompletionListener { override def onTaskCompletion(context: TaskContext): Unit = f(context) }) } + // TODO(josh): this used to be an overload of addTaskFailureListener(), but the overload + // became ambiguous under Scala 2.12. For now, I'm renaming this in order to get the code to + // compile, but we need to figure out a long-term solution which maintains at least source + // compatibility (and probably binary compatibility) for Java callers. /** * Adds a listener to be executed on task failure. Adding a listener to an already failed task * will result in that listener being called immediately. */ - def addTaskFailureListener(listener: TaskFailureListener): TaskContext + def addJavaFriendlyTaskFailureListener(listener: TaskFailureListener): TaskContext /** * Adds a listener to be executed on task failure. Adding a listener to an already failed task * will result in that listener being called immediately. */ def addTaskFailureListener(f: (TaskContext, Throwable) => Unit): TaskContext = { - addTaskFailureListener(new TaskFailureListener { + addJavaFriendlyTaskFailureListener(new TaskFailureListener { override def onTaskFailure(context: TaskContext, error: Throwable): Unit = f(context, error) }) } |