Fixed several memory and thread leaks. See #1404
* Dispatchers need Scheduler to be able to shutdown themselves. Stop Scheduler after dispatchers. * Changed CallingThreadDispatcher global object to Extension, since it holds map of references to mailboxes. Will be GC:ed when system is GC:ed. * Made testActor lazy, since it is not used in all tests, and it creates CallingThreadDispatcher. * Activated some java tests that were not running * Many tests were not stopping created ActorSystems. VERY IMPORTANT TO STOP ActorSystem in tests. Use AkkaSpec as much as possible. * Used profiler to verify (and find) dangling ActorSystemImpl and threads from dispatchers. * FutureSpec creates ForkJoinPool threads that are not cleared, but number of threads don't grow so it's not a problem.
This commit is contained in:
parent
035f514843
commit
b488d70f54
31 changed files with 232 additions and 105 deletions
|
|
@ -2,21 +2,36 @@ package akka.actor;
|
|||
|
||||
import akka.actor.ActorSystem;
|
||||
import akka.japi.Creator;
|
||||
import akka.testkit.AkkaSpec;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class JavaAPI {
|
||||
|
||||
private ActorSystem system = ActorSystem.create();
|
||||
private static ActorSystem system;
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeAll() {
|
||||
system = ActorSystem.create("JavaAPI", AkkaSpec.testConf());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterAll() {
|
||||
system.stop();
|
||||
system = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
void mustBeAbleToCreateActorRefFromClass() {
|
||||
public void mustBeAbleToCreateActorRefFromClass() {
|
||||
ActorRef ref = system.actorOf(JavaAPITestActor.class);
|
||||
assertNotNull(ref);
|
||||
}
|
||||
|
||||
@Test
|
||||
void mustBeAbleToCreateActorRefFromFactory() {
|
||||
public void mustBeAbleToCreateActorRefFromFactory() {
|
||||
ActorRef ref = system.actorOf(new Props().withCreator(new Creator<Actor>() {
|
||||
public Actor create() {
|
||||
return new JavaAPITestActor();
|
||||
|
|
@ -26,7 +41,7 @@ public class JavaAPI {
|
|||
}
|
||||
|
||||
@Test
|
||||
void mustAcceptSingleArgTell() {
|
||||
public void mustAcceptSingleArgTell() {
|
||||
ActorRef ref = system.actorOf(JavaAPITestActor.class);
|
||||
ref.tell("hallo");
|
||||
ref.tell("hallo", ref);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue