Skip to content

Commit 5daa887

Browse files
committed
fix binary compatibility
1 parent f96de16 commit 5daa887

File tree

8 files changed

+27
-14
lines changed

8 files changed

+27
-14
lines changed

akka-actor-typed-tests/src/test/java/jdocs/akka/typed/RouterTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ static Behavior<Void> showPoolRouting() {
124124
Routers.pool(
125125
poolSize,
126126
// make sure the workers are restarted if they fail
127-
Behaviors.supervise(Worker.create()).onAnyFailure(SupervisorStrategy.restart()));
127+
Behaviors.supervise(Worker.create()).onFailure(SupervisorStrategy.restart()));
128128
ActorRef<Worker.Command> router = context.spawn(pool, "worker-pool");
129129

130130
for (int i = 0; i < 10; i++) {

akka-actor-typed-tests/src/test/java/jdocs/akka/typed/supervision/SupervisionCompileOnlyTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public Got(int n) {
3333

3434
// #top-level
3535
public static Behavior<Command> create() {
36-
return Behaviors.supervise(counter(1)).onAnyFailure(SupervisorStrategy.restart());
36+
return Behaviors.supervise(counter(1)).onFailure(SupervisorStrategy.restart());
3737
}
3838
// #top-level
3939

@@ -105,7 +105,7 @@ static Behavior<String> parent() {
105105
return Behaviors.same();
106106
});
107107
}))
108-
.onAnyFailure(SupervisorStrategy.restart());
108+
.onFailure(SupervisorStrategy.restart());
109109
}
110110
// #restart-stop-children
111111

@@ -117,16 +117,16 @@ static Behavior<String> parent2() {
117117
final ActorRef<String> child2 = ctx.spawn(child(0), "child2");
118118

119119
// supervision strategy inside the setup to not recreate children on restart
120-
return Behaviors.<String>supervise(
121-
Behaviors.receiveMessage(
120+
return Behaviors.supervise(
121+
Behaviors.<String>receiveMessage(
122122
msg -> {
123123
// message handling that might throw an exception
124124
String[] parts = msg.split(" ");
125125
child1.tell(parts[0]);
126126
child2.tell(parts[1]);
127127
return Behaviors.same();
128128
}))
129-
.onAnyFailure(SupervisorStrategy.restart().withStopChildren(false));
129+
.onFailure(SupervisorStrategy.restart().withStopChildren(false));
130130
});
131131
}
132132
// #restart-keep-children

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ abstract class ExtensibleBehavior[T] extends Behavior[T](BehaviorTags.Extensible
118118
* A behavior type that could be supervised, Not for user extension.
119119
*/
120120
@InternalApi
121-
final class SuperviseBehavior[T] private[akka] (val wrapped: Behavior[T])
121+
class SuperviseBehavior[T] private[akka] (val wrapped: Behavior[T])
122122
extends Behavior[T](BehaviorTags.SuperviseBehavior) {
123123
private final val ThrowableClassTag = ClassTag(classOf[Throwable])
124124

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,19 @@ object Behaviors {
244244
* .onFailure[IndexOutOfBoundsException](SupervisorStrategy.resume) // resume for IndexOutOfBoundsException exceptions
245245
* }}}
246246
*/
247-
def supervise[T](wrapped: Behavior[T]): SuperviseBehavior[T] =
248-
scaladsl.Behaviors.supervise(wrapped)
247+
def supervise[T](wrapped: Behavior[T]): Supervise[T] =
248+
new Supervise[T](wrapped)
249+
250+
final class Supervise[T] private[akka] (wrapped: Behavior[T]) extends SuperviseBehavior(wrapped) {
251+
252+
/**
253+
* Specify the [[SupervisorStrategy]] to be invoked when the wrapped behavior throws.
254+
*
255+
* All non-fatal (see [[scala.util.control.NonFatal]]) exceptions types will be handled using the given strategy.
256+
*/
257+
def onFailure(strategy: SupervisorStrategy): Behavior[T] =
258+
onFailure(classOf[Exception], strategy)
259+
}
249260

250261
/**
251262
* Transform the incoming messages by placing a funnel in front of the wrapped `Behavior`: the supplied

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,10 @@ object Behaviors {
215215
* .onFailure[IndexOutOfBoundsException](SupervisorStrategy.resume) // resume for IndexOutOfBoundsException exceptions
216216
* }}}
217217
*/
218-
def supervise[T](wrapped: Behavior[T]): SuperviseBehavior[T] =
219-
new SuperviseBehavior[T](wrapped)
218+
def supervise[T](wrapped: Behavior[T]): Supervise[T] =
219+
new Supervise[T](wrapped)
220+
221+
final class Supervise[T] private[akka] (wrapped: Behavior[T]) extends SuperviseBehavior(wrapped)
220222

221223
/**
222224
* Support for scheduled `self` messages in an actor.

akka-cluster-typed/src/test/java/jdocs/akka/cluster/typed/SingletonCompileOnlyTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public static void backoff() {
111111
singleton.init(
112112
SingletonActor.of(
113113
Behaviors.supervise(Counter.create())
114-
.onAnyFailure(
114+
.onFailure(
115115
SupervisorStrategy.restartWithBackoff(
116116
Duration.ofSeconds(1), Duration.ofSeconds(10), 0.2)),
117117
"GlobalCounter"));

akka-docs/src/test/java/jdocs/typed/tutorial_1/ActorHierarchyExperiments.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ private SupervisingActor(ActorContext<String> context) {
111111
super(context);
112112
child =
113113
context.spawn(
114-
Behaviors.supervise(SupervisedActor.create()).onAnyFailure(SupervisorStrategy.restart()),
114+
Behaviors.supervise(SupervisedActor.create()).onFailure(SupervisorStrategy.restart()),
115115
"supervised-actor");
116116
}
117117

akka-persistence-typed-tests/src/test/java/akka/persistence/typed/javadsl/EventSourcedBehaviorJavaDslTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ protected void log() {
387387
public void workWhenWrappedInOtherBehavior() {
388388
Behavior<Command> behavior =
389389
Behaviors.supervise(counter(PersistenceId.ofUniqueId("c6")))
390-
.onAnyFailure(
390+
.onFailure(
391391
SupervisorStrategy.restartWithBackoff(
392392
Duration.ofSeconds(1), Duration.ofSeconds(10), 0.1));
393393
ActorRef<Command> c = testKit.spawn(behavior);

0 commit comments

Comments
 (0)