Closed scabug closed 13 years ago
Imported From: https://issues.scala-lang.org/browse/SI-694?orig=1 Reporter: cbordelo
@ingoem said: If you are not sure whether it's a bug or you are doing something wrong, you should ask on the mailing lists first. You will usually get a much prompter answer there. Thanks :)
@phaller said:
Actually, when passing "x" as argument, the above code must block: when reacting to the message that is sent by the inner actor, sender
(correctly) refers to the inner actor.
To make the program work, you have to save the original sender (from the outermost !?
) in a local variable (call it s
):
actor {
react {
case "" => sender ! None
case _ =>
val s = sender // ADDED
actor {
react {
case _ => sender ! None
}
} ! ""
react { case _ => s ! None } // CHANGED
}
} !? what
Then, the program sends the reply to the right actor and returns as expected.
However, the fact that the original program did not hang when replacing the outer react
with receive
exposed a bug: inside the last react
, sender
incorrectly referred to the sender of the outer receive
.
This bug is fixed in revision r14487.
Thanks for reporting this anomalous behavior.
@odersky said: Milestone 2.7.1 deleted
Maybe i just don't understand something altho I read the scaladocs, have browsed code, read the preprint actors chapter.
I have a hung actors program when run below code with "x" as argument
But the main should have gotten a None from the outer actor that it waited synchronously on. Note that if run the code above with "" argument then it completes again with the None getting to the outer actor. And if you change the outer actor (top level that main waits on) to use receive, then it also completes.
I'm testing with the 2.7.0 scala and JDK 5 (1.5_10) on Solaris 10.
If you discover what I'm doing wrong here, pls point it out and/or show me the documentation. send to bord@iscp.telcordia.com