forked from dragos/akka
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
akka#21574 Fix dispatcher use after system termination
- Loading branch information
Showing
2 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
akka-actor-tests/src/test/scala/akka/dispatch/DispatcherShutdownSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package akka.dispatch | ||
|
||
import akka.actor.ActorSystem | ||
import akka.testkit.TestKit | ||
import java.lang.management.ManagementFactory | ||
import org.scalatest.{ Matchers, WordSpec } | ||
import scala.concurrent.{ Await, Future } | ||
import scala.concurrent.duration._ | ||
|
||
class DispatcherShutdownSpec extends WordSpec with Matchers { | ||
|
||
"akka dispatcher" should { | ||
|
||
"eventualy shutdown when used after system terminate" in { | ||
|
||
val threads = ManagementFactory.getThreadMXBean() | ||
def threadCount = threads | ||
.dumpAllThreads(false, false).toList | ||
.map(_.getThreadName) | ||
.filter(_.startsWith("DispatcherShutdownSpec-akka.actor.default")) | ||
.size | ||
|
||
val system = ActorSystem("DispatcherShutdownSpec") | ||
threadCount should be > 0 | ||
|
||
Await.ready(system.terminate(), 1.second) | ||
Await.ready(Future(akka.Done)(system.dispatcher), 1.second) | ||
|
||
TestKit.awaitCond(threadCount == 0, 3.second) | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters