add ActorRef.noSender() for the Java API, see #3429
- Actor.noSender is not accessible from Java, but it was in 2.1 so don’t remove - replaced all “null” in doc tests with ActorRef.noSender()
This commit is contained in:
parent
6c96485b26
commit
a2a646af4e
24 changed files with 92 additions and 79 deletions
|
|
@ -189,11 +189,11 @@ public class FSMDocTest {
|
|||
public void mustBunch() {
|
||||
final ActorRef buncher = system.actorOf(Props.create(MyFSM.class));
|
||||
final TestProbe probe = new TestProbe(system);
|
||||
buncher.tell(new SetTarget(probe.ref()), null);
|
||||
buncher.tell(new Queue(1), null);
|
||||
buncher.tell(new Queue(2), null);
|
||||
buncher.tell(flush, null);
|
||||
buncher.tell(new Queue(3), null);
|
||||
buncher.tell(new SetTarget(probe.ref()), ActorRef.noSender());
|
||||
buncher.tell(new Queue(1), ActorRef.noSender());
|
||||
buncher.tell(new Queue(2), ActorRef.noSender());
|
||||
buncher.tell(flush, ActorRef.noSender());
|
||||
buncher.tell(new Queue(3), ActorRef.noSender());
|
||||
final Batch b = probe.expectMsgClass(Batch.class);
|
||||
assert b.objects.size() == 2;
|
||||
assert b.objects.contains(1);
|
||||
|
|
|
|||
|
|
@ -179,21 +179,21 @@ public class FaultHandlingTest {
|
|||
//#create
|
||||
|
||||
//#resume
|
||||
child.tell(42, null);
|
||||
child.tell(42, ActorRef.noSender());
|
||||
assert Await.result(ask(child, "get", 5000), timeout).equals(42);
|
||||
child.tell(new ArithmeticException(), null);
|
||||
child.tell(new ArithmeticException(), ActorRef.noSender());
|
||||
assert Await.result(ask(child, "get", 5000), timeout).equals(42);
|
||||
//#resume
|
||||
|
||||
//#restart
|
||||
child.tell(new NullPointerException(), null);
|
||||
child.tell(new NullPointerException(), ActorRef.noSender());
|
||||
assert Await.result(ask(child, "get", 5000), timeout).equals(0);
|
||||
//#restart
|
||||
|
||||
//#stop
|
||||
final TestProbe probe = new TestProbe(system);
|
||||
probe.watch(child);
|
||||
child.tell(new IllegalArgumentException(), null);
|
||||
child.tell(new IllegalArgumentException(), ActorRef.noSender());
|
||||
probe.expectMsgClass(Terminated.class);
|
||||
//#stop
|
||||
|
||||
|
|
@ -202,7 +202,7 @@ public class FaultHandlingTest {
|
|||
Props.create(Child.class), 5000), timeout);
|
||||
probe.watch(child);
|
||||
assert Await.result(ask(child, "get", 5000), timeout).equals(0);
|
||||
child.tell(new Exception(), null);
|
||||
child.tell(new Exception(), ActorRef.noSender());
|
||||
probe.expectMsgClass(Terminated.class);
|
||||
//#escalate-kill
|
||||
|
||||
|
|
@ -211,9 +211,9 @@ public class FaultHandlingTest {
|
|||
supervisor = system.actorOf(superprops);
|
||||
child = (ActorRef) Await.result(ask(supervisor,
|
||||
Props.create(Child.class), 5000), timeout);
|
||||
child.tell(23, null);
|
||||
child.tell(23, ActorRef.noSender());
|
||||
assert Await.result(ask(child, "get", 5000), timeout).equals(23);
|
||||
child.tell(new Exception(), null);
|
||||
child.tell(new Exception(), ActorRef.noSender());
|
||||
assert Await.result(ask(child, "get", 5000), timeout).equals(0);
|
||||
//#escalate-restart
|
||||
//#testkit
|
||||
|
|
|
|||
|
|
@ -16,6 +16,6 @@ public class FirstUntypedActor extends UntypedActor {
|
|||
|
||||
public void onReceive(Object message) {
|
||||
myActor.forward(message, getContext());
|
||||
myActor.tell(PoisonPill.getInstance(), null);
|
||||
myActor.tell(PoisonPill.getInstance(), ActorRef.noSender());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public class InboxDocTest {
|
|||
//#watch
|
||||
final Inbox inbox = Inbox.create(system);
|
||||
inbox.watch(target);
|
||||
target.tell(PoisonPill.getInstance(), null);
|
||||
target.tell(PoisonPill.getInstance(), ActorRef.noSender());
|
||||
assert inbox.receive(Duration.create(1, TimeUnit.SECONDS)) instanceof Terminated;
|
||||
//#watch
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public class SchedulerDocTest {
|
|||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
testActor.tell(System.currentTimeMillis(), null);
|
||||
testActor.tell(System.currentTimeMillis(), ActorRef.noSender());
|
||||
}
|
||||
}, system.dispatcher());
|
||||
//#schedule-one-off-thunk
|
||||
|
|
|
|||
|
|
@ -370,7 +370,7 @@ public class UntypedActorDocTest {
|
|||
master.tell("", getRef());
|
||||
final ActorRef victim = expectMsgClass(ActorRef.class);
|
||||
//#kill
|
||||
victim.tell(akka.actor.Kill.getInstance(), null);
|
||||
victim.tell(akka.actor.Kill.getInstance(), ActorRef.noSender());
|
||||
//#kill
|
||||
expectMsgEquals("killed");
|
||||
expectMsgEquals("stopped");
|
||||
|
|
|
|||
|
|
@ -44,12 +44,12 @@ public class UntypedActorSwapper {
|
|||
public static void main(String... args) {
|
||||
ActorSystem system = ActorSystem.create("MySystem");
|
||||
ActorRef swap = system.actorOf(Props.create(Swapper.class));
|
||||
swap.tell(SWAP, null); // logs Hi
|
||||
swap.tell(SWAP, null); // logs Ho
|
||||
swap.tell(SWAP, null); // logs Hi
|
||||
swap.tell(SWAP, null); // logs Ho
|
||||
swap.tell(SWAP, null); // logs Hi
|
||||
swap.tell(SWAP, null); // logs Ho
|
||||
swap.tell(SWAP, ActorRef.noSender()); // logs Hi
|
||||
swap.tell(SWAP, ActorRef.noSender()); // logs Ho
|
||||
swap.tell(SWAP, ActorRef.noSender()); // logs Hi
|
||||
swap.tell(SWAP, ActorRef.noSender()); // logs Ho
|
||||
swap.tell(SWAP, ActorRef.noSender()); // logs Hi
|
||||
swap.tell(SWAP, ActorRef.noSender()); // logs Ho
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public class DurableMailboxDocTest {
|
|||
ActorRef myActor = system.actorOf(Props.create(MyUntypedActor.class).
|
||||
withDispatcher("my-dispatcher"), "myactor");
|
||||
//#dispatcher-config-use
|
||||
myActor.tell("test", null);
|
||||
myActor.tell("test", ActorRef.noSender());
|
||||
}
|
||||
|
||||
public static class MyUntypedActor extends UntypedActor {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue