remove ActorRef#tell(Any), see #3293

also remove FakeActorRef from SerCompSpec
This commit is contained in:
Roland 2013-05-02 21:10:33 +02:00
parent b3db19ee05
commit ddf2117ed7
9 changed files with 17 additions and 69 deletions

View file

@ -65,11 +65,4 @@ public class JavaAPI {
}));
assertNotNull(ref);
}
@Test
public void mustAcceptSingleArgTell() {
ActorRef ref = system.actorOf(Props.create(JavaAPITestActor.class));
ref.tell("hallo");
ref.tell("hallo", ref);
}
}

View file

@ -363,35 +363,22 @@ class SerializationCompatibilitySpec extends AkkaSpec(SerializationTests.mostlyR
"0000000000010200007870")
}
"be preserved for the Supervise SystemMessage" in {
verify(Supervise(FakeActorRef("child"), true),
verify(Supervise(null, true),
"aced00057372001e616b6b612e64697370617463682e7379736d73672e5375706572766973650000" +
"0000000000010200025a00056173796e634c00056368696c647400154c616b6b612f6163746f722f" +
"4163746f725265663b7870017372001f616b6b612e73657269616c697a6174696f6e2e46616b6541" +
"63746f7252656600000000000000010200014c00046e616d657400124c6a6176612f6c616e672f53" +
"7472696e673b7872001b616b6b612e6163746f722e496e7465726e616c4163746f72526566869e6c" +
"3669e60e5f02000078720013616b6b612e6163746f722e4163746f72526566c3585dde655f469402" +
"000078707400056368696c64")
"4163746f725265663b78700170")
}
"be preserved for the Watch SystemMessage" in {
verify(Watch(FakeActorRef("watchee"), FakeActorRef("watcher")),
verify(Watch(null, null),
"aced00057372001a616b6b612e64697370617463682e7379736d73672e5761746368000000000000" +
"00010200024c00077761746368656574001d4c616b6b612f6163746f722f496e7465726e616c4163" +
"746f725265663b4c00077761746368657271007e000178707372001f616b6b612e73657269616c69" +
"7a6174696f6e2e46616b654163746f7252656600000000000000010200014c00046e616d65740012" +
"4c6a6176612f6c616e672f537472696e673b7872001b616b6b612e6163746f722e496e7465726e61" +
"6c4163746f72526566869e6c3669e60e5f02000078720013616b6b612e6163746f722e4163746f72" +
"526566c3585dde655f46940200007870740007776174636865657371007e00037400077761746368" +
"6572")
"746f725265663b4c00077761746368657271007e000178707070")
}
"be preserved for the Unwatch SystemMessage" in {
verify(Unwatch(FakeActorRef("watchee"), FakeActorRef("watcher")),
verify(Unwatch(null, null),
"aced00057372001c616b6b612e64697370617463682e7379736d73672e556e776174636800000000" +
"000000010200024c0007776174636865657400154c616b6b612f6163746f722f4163746f72526566" +
"3b4c00077761746368657271007e000178707372001f616b6b612e73657269616c697a6174696f6e" +
"2e46616b654163746f7252656600000000000000010200014c00046e616d657400124c6a6176612f" +
"6c616e672f537472696e673b7872001b616b6b612e6163746f722e496e7465726e616c4163746f72" +
"526566869e6c3669e60e5f02000078720013616b6b612e6163746f722e4163746f72526566c3585d" +
"de655f46940200007870740007776174636865657371007e000374000777617463686572")
"3b4c00077761746368657271007e000178707070")
}
"be preserved for the NoMessage SystemMessage" in {
verify(NoMessage,
@ -400,15 +387,11 @@ class SerializationCompatibilitySpec extends AkkaSpec(SerializationTests.mostlyR
}
"be preserved for the Failed SystemMessage" in {
// Using null as the cause to avoid a large serialized message and JDK differences
verify(Failed(FakeActorRef("child"), cause = null, uid = 0),
verify(Failed(null, cause = null, uid = 0),
"aced00057372001b616b6b612e64697370617463682e7379736d73672e4661696c65640000000000" +
"0000010200034900037569644c000563617573657400154c6a6176612f6c616e672f5468726f7761" +
"626c653b4c00056368696c647400154c616b6b612f6163746f722f4163746f725265663b78700000" +
"0000707372001f616b6b612e73657269616c697a6174696f6e2e46616b654163746f725265660000" +
"0000000000010200014c00046e616d657400124c6a6176612f6c616e672f537472696e673b787200" +
"1b616b6b612e6163746f722e496e7465726e616c4163746f72526566869e6c3669e60e5f02000078" +
"720013616b6b612e6163746f722e4163746f72526566c3585dde655f469402000078707400056368" +
"696c64")
"00007070")
}
}
}
@ -450,21 +433,3 @@ protected[akka] class TestSerializer extends Serializer {
protected[akka] case class FakeThrowable(msg: String) extends Throwable(msg) with Serializable {
override def fillInStackTrace = null
}
@SerialVersionUID(1)
protected[akka] case class FakeActorRef(name: String) extends InternalActorRef with ActorRefScope {
override def path = RootActorPath(Address("proto", "SomeSystem"), name)
override def forward(message: Any)(implicit context: ActorContext) = ???
@deprecated("Use context.watch(actor) and receive Terminated(actor)", "2.2") override def isTerminated = ???
override def start() = ???
override def resume(causedByFailure: Throwable) = ???
override def suspend() = ???
override def restart(cause: Throwable) = ???
override def stop() = ???
override def sendSystemMessage(message: SystemMessage) = ???
override def provider = ???
override def getParent = ???
override def getChild(name: Iterator[String]) = ???
override def isLocal = ???
override def !(message: Any)(implicit sender: ActorRef = Actor.noSender) = ???
}

View file

@ -100,16 +100,6 @@ abstract class ActorRef extends java.lang.Comparable[ActorRef] with Serializable
else x
}
/**
* Sends the specified message to the sender, i.e. fire-and-forget semantics.
*
* <pre>
* actor.tell(message);
* </pre>
*/
@deprecated("use the two-arg variant (typically getSelf() as second arg)", "2.1")
final def tell(msg: Any): Unit = this.!(msg)(null: ActorRef)
/**
* Java API: Sends the specified message to the sender, i.e. fire-and-forget
* semantics, including the sender reference if possible (pass `null` if

View file

@ -63,11 +63,11 @@ import akka.japi.{ Creator }
*
* if (msg.equals("UseSender")) {
* // Reply to original sender of message
* getSender().tell(msg + ":" + getSelf());
* getSender().tell(msg, getSelf());
*
* } else if (msg.equals("SendToSelf")) {
* // Send message to the actor itself recursively
* getSelf().tell("SomeOtherMessage");
* getSelf().tell("SomeOtherMessage", getSelf());
*
* } else if (msg.equals("ErrorKernelWithDirectReply")) {
* // Send work to one-off child which will reply directly to original sender
@ -83,7 +83,7 @@ import akka.japi.{ Creator }
*
* final Reply reply = (Reply) message;
* // might want to do some processing/book-keeping here
* reply.sender.tell(reply.result);
* reply.sender.tell(reply.result, getSelf());
*
* } else throw new IllegalArgumentException("Unknown message: " + message);
* }

View file

@ -17,7 +17,7 @@ package akka.actor
* public void onReceive(Object msg) {
* if (msg instanceof String) {
* if (count < 0) {
* getSender().tell(new Integer(((String) msg).length()));
* getSender().tell(new Integer(((String) msg).length()), getSelf());
* } else if (count == 2) {
* count = -1;
* unstashAll();

View file

@ -291,7 +291,7 @@ filling in will they be transferred into the real mailbox. Thus,
final Props props = ...
// this actor uses MyCustomMailbox, which is assumed to be a singleton
system.actorOf(props.withDispatcher("myCustomMailbox").tell("bang");
system.actorOf(props.withDispatcher("myCustomMailbox").tell("bang", sender);
assert(MyCustomMailbox.getInstance().getLastEnqueued().equals("bang"));
will probably fail; you will have to allow for some time to pass and retry the

View file

@ -28,7 +28,7 @@ by the ``ExecutionContexts`` class to wrap ``Executors`` and ``ExecutorServices`
Use with Actors
---------------
There are generally two ways of getting a reply from an ``UntypedActor``: the first is by a sent message (``actorRef.tell(msg)``),
There are generally two ways of getting a reply from an ``UntypedActor``: the first is by a sent message (``actorRef.tell(msg, sender)``),
which only works if the original sender was an ``UntypedActor``) and the second is through a ``Future``.
Using the ``ActorRef``\'s ``ask`` method to send a message will return a ``Future``.

View file

@ -27,7 +27,7 @@ Sending a message to a router is easy.
.. code-block:: java
router.tell(new MyMsg());
router.tell(new MyMsg(), sender);
A router actor forwards messages to its routees according to its routing policy.

View file

@ -467,7 +467,7 @@ an ``onComplete``-handler on the future to effect the submission of the
aggregated :class:`Result` to another actor.
Using ``ask`` will send a message to the receiving Actor as with ``tell``, and
the receiving actor must reply with ``getSender().tell(reply)`` in order to
the receiving actor must reply with ``getSender().tell(reply, getSelf())`` in order to
complete the returned :class:`Future` with a value. The ``ask`` operation
involves creating an internal actor for handling this reply, which needs to
have a timeout after which it is destroyed in order not to leak resources; see
@ -533,7 +533,7 @@ Reply to messages
If you want to have a handle for replying to a message, you can use
``getSender()``, which gives you an ActorRef. You can reply by sending to
that ActorRef with ``getSender().tell(replyMsg)``. You can also store the ActorRef
that ActorRef with ``getSender().tell(replyMsg, getSelf())``. You can also store the ActorRef
for replying later, or passing on to other actors. If there is no sender (a
message was sent without an actor or future context) then the sender
defaults to a 'dead-letter' actor ref.