Skip to content
This repository was archived by the owner on Feb 23, 2018. It is now read-only.

Commit ae58874

Browse files
author
phaller
committed
Closes #3838. Review by prokopec.
git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@24466 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
1 parent a79761a commit ae58874

File tree

3 files changed

+31
-12
lines changed

3 files changed

+31
-12
lines changed

src/actors/scala/actors/Actor.scala

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -589,18 +589,21 @@ trait Actor extends AbstractActor with ReplyReactor with ActorCanReply with Inpu
589589
done = true
590590
receiveTimeout
591591
} else {
592-
waitingFor = f
593-
received = None
594-
isSuspended = true
595-
val thisActor = this
596-
onTimeout = Some(new TimerTask {
597-
def run() { thisActor.send(TIMEOUT, thisActor) }
598-
})
599-
Actor.timer.schedule(onTimeout.get, msec)
600-
scheduler.managedBlock(blocker)
601-
drainSendBuffer(mailbox)
602-
// keep going
603-
() => {}
592+
if (onTimeout.isEmpty) {
593+
waitingFor = f
594+
received = None
595+
isSuspended = true
596+
val thisActor = this
597+
onTimeout = Some(new TimerTask {
598+
def run() { thisActor.send(TIMEOUT, thisActor) }
599+
})
600+
Actor.timer.schedule(onTimeout.get, msec)
601+
scheduler.managedBlock(blocker)
602+
drainSendBuffer(mailbox)
603+
// keep going
604+
() => {}
605+
} else
606+
sys.error("unhandled timeout")
604607
}
605608
}
606609
todo()

test/files/jvm/t3838.check

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
caught java.lang.RuntimeException: unhandled timeout

test/files/jvm/t3838.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import scala.actors.Actor._
2+
3+
object Test {
4+
def main(args: Array[String]) {
5+
actor {
6+
try {
7+
receiveWithin(1) {
8+
case str: String => println(str)
9+
}
10+
} catch {
11+
case e: Exception => println("caught "+e)
12+
}
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)