File tree Expand file tree Collapse file tree 4 files changed +23
-17
lines changed
akka-actor-typed/src/main
mima-filters/2.9.6.backwards.excludes Expand file tree Collapse file tree 4 files changed +23
-17
lines changed Original file line number Diff line number Diff line change 1+ # Change the return type of `Behaviors.supervise` to support flattened supervision
2+ ProblemFilters.exclude[IncompatibleResultTypeProblem]("akka.actor.typed.javadsl.Behaviors#Supervise.onFailure")
3+ ProblemFilters.exclude[IncompatibleResultTypeProblem]("akka.actor.typed.scaladsl.Behaviors#Supervise.onFailure")
4+ ProblemFilters.exclude[IncompatibleResultTypeProblem]("akka.actor.typed.scaladsl.Behaviors#Supervise.onFailure$extension")
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ package akka.actor.typed
77import scala .annotation .switch
88import scala .annotation .tailrec
99import scala .reflect .ClassTag
10+
1011import akka .actor .InvalidMessageException
1112import akka .actor .typed .internal .BehaviorImpl
1213import akka .actor .typed .internal .BehaviorImpl .DeferredBehavior
@@ -130,24 +131,12 @@ class SuperviseBehavior[T] private[akka] (val wrapped: Behavior[T])
130131 }
131132
132133 /**
133- * Java API:
134134 * Specify the [[SupervisorStrategy ]] to be invoked when the wrapped behavior throws.
135135 *
136136 * Only exceptions of the given type (and their subclasses) will be handled by this supervision behavior.
137137 */
138- def onFailure [Thr <: Throwable ](clazz : Class [Thr ], strategy : SupervisorStrategy ): SuperviseBehavior [T ] = {
138+ def onFailure [Thr <: Throwable ](clazz : Class [Thr ], strategy : SupervisorStrategy ): SuperviseBehavior [T ] =
139139 onFailure(strategy)(ClassTag (clazz))
140- }
141-
142- /**
143- * Java API:
144- * Specify the [[SupervisorStrategy ]] to be invoked when the wrapped behavior throws.
145- *
146- * Only exceptions of the given type (and their subclasses) will be handled by this supervision behavior.
147- */
148- def onAnyFailure [Thr <: Throwable ](strategy : SupervisorStrategy ): SuperviseBehavior [T ] = {
149- onFailure(classOf [Exception ], strategy)
150- }
151140
152141 private [akka] def unwrap : Behavior [T ] = wrapped
153142}
Original file line number Diff line number Diff line change @@ -247,15 +247,23 @@ object Behaviors {
247247 def supervise [T ](wrapped : Behavior [T ]): Supervise [T ] =
248248 new Supervise [T ](wrapped)
249249
250- final class Supervise [T ] private [akka] (wrapped : Behavior [T ]) extends SuperviseBehavior (wrapped) {
250+ final class Supervise [T ] private [akka] (wrapped : Behavior [T ]) {
251+
252+ /**
253+ * Specify the [[SupervisorStrategy ]] to be invoked when the wrapped behavior throws.
254+ *
255+ * Only exceptions of the given type (and their subclasses) will be handled by this supervision behavior.
256+ */
257+ def onFailure [Thr <: Throwable ](clazz : Class [Thr ], strategy : SupervisorStrategy ): SuperviseBehavior [T ] =
258+ new SuperviseBehavior [T ](wrapped).onFailure(clazz, strategy)
251259
252260 /**
253261 * Specify the [[SupervisorStrategy ]] to be invoked when the wrapped behavior throws.
254262 *
255263 * All non-fatal (see [[scala.util.control.NonFatal ]]) exceptions types will be handled using the given strategy.
256264 */
257265 def onFailure (strategy : SupervisorStrategy ): Behavior [T ] =
258- onFailure( classOf [ Exception ], strategy)
266+ new SuperviseBehavior [ T ](wrapped).onFailure( strategy)
259267 }
260268
261269 /**
Original file line number Diff line number Diff line change @@ -6,7 +6,6 @@ package akka.actor.typed
66package scaladsl
77
88import scala .reflect .ClassTag
9-
109import akka .actor .typed .internal ._
1110import akka .annotation .{ DoNotInherit , InternalApi }
1211
@@ -218,7 +217,13 @@ object Behaviors {
218217 def supervise [T ](wrapped : Behavior [T ]): Supervise [T ] =
219218 new Supervise [T ](wrapped)
220219
221- final class Supervise [T ] private [akka] (wrapped : Behavior [T ]) extends SuperviseBehavior (wrapped)
220+ final class Supervise [T ] private [akka] (val wrapped : Behavior [T ]) extends AnyVal {
221+
222+ /** Specify the [[SupervisorStrategy ]] to be invoked when the wrapped behavior throws. */
223+ def onFailure [Thr <: Throwable ](strategy : SupervisorStrategy )(implicit tag : ClassTag [Thr ]): SuperviseBehavior [T ] = {
224+ new SuperviseBehavior [T ](wrapped).onFailure(strategy)(tag)
225+ }
226+ }
222227
223228 /**
224229 * Support for scheduled `self` messages in an actor.
You can’t perform that action at this time.
0 commit comments