Skip to content

Commit 7654d09

Browse files
committed
binary compatibility
1 parent 5daa887 commit 7654d09

File tree

4 files changed

+23
-17
lines changed

4 files changed

+23
-17
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
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")

akka-actor-typed/src/main/scala/akka/actor/typed/Behavior.scala

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package akka.actor.typed
77
import scala.annotation.switch
88
import scala.annotation.tailrec
99
import scala.reflect.ClassTag
10+
1011
import akka.actor.InvalidMessageException
1112
import akka.actor.typed.internal.BehaviorImpl
1213
import 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
}

akka-actor-typed/src/main/scala/akka/actor/typed/javadsl/Behaviors.scala

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff 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
/**

akka-actor-typed/src/main/scala/akka/actor/typed/scaladsl/Behaviors.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package akka.actor.typed
66
package scaladsl
77

88
import scala.reflect.ClassTag
9-
109
import akka.actor.typed.internal._
1110
import 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.

0 commit comments

Comments
 (0)