Skip to content

Commit ab63a25

Browse files
committed
Split ActorSystem creation into javadsl and scaladsl
1 parent 85d3bca commit ab63a25

File tree

181 files changed

+732
-445
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

181 files changed

+732
-445
lines changed

actor-tests/src/test/java/org/apache/pekko/actor/ActorSystemTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
package org.apache.pekko.actor;
1515

16+
import org.apache.pekko.actor.javadsl.ActorSystem;
1617
import org.apache.pekko.testkit.PekkoJUnitActorSystemResource;
1718
import org.junit.Before;
1819
import org.junit.Rule;
@@ -39,7 +40,7 @@ public void beforeEach() {
3940

4041
@Test
4142
public void testGetWhenTerminated() throws Exception {
42-
system.terminate();
43+
system.terminateAsync();
4344
final CompletionStage<Terminated> cs = system.getWhenTerminated();
4445
cs.toCompletableFuture().get(2, SECONDS);
4546
}

actor-tests/src/test/scala/org/apache/pekko/actor/ActorSystemDispatcherSpec.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ class ActorSystemDispatchersSpec extends PekkoSpec(ConfigFactory.parseString("""
5454
val ecProbe = TestProbe()
5555
val ec = new SnitchingExecutionContext(ecProbe.ref, ExecutionContexts.global())
5656

57-
val system2 = ActorSystem(name = "ActorSystemDispatchersSpec-passed-in-ec", defaultExecutionContext = Some(ec))
57+
val system2 = pekko.actor.scaladsl.ActorSystem(name = "ActorSystemDispatchersSpec-passed-in-ec",
58+
defaultExecutionContext = Some(ec))
5859

5960
try {
6061
val ref = system2.actorOf(Props(new Actor {
@@ -79,7 +80,7 @@ class ActorSystemDispatchersSpec extends PekkoSpec(ConfigFactory.parseString("""
7980
val ec = new SnitchingExecutionContext(ecProbe.ref, ExecutionContexts.global())
8081

8182
val config = ConfigFactory.parseString("pekko.actor.default-dispatcher.executor = \"fork-join-executor\"")
82-
val system2 = ActorSystem(
83+
val system2 = pekko.actor.scaladsl.ActorSystem(
8384
name = "ActorSystemDispatchersSpec-ec-configured",
8485
config = Some(config),
8586
defaultExecutionContext = Some(ec))
@@ -103,7 +104,7 @@ class ActorSystemDispatchersSpec extends PekkoSpec(ConfigFactory.parseString("""
103104
}
104105

105106
"provide a single place to override the internal dispatcher" in {
106-
val sys = ActorSystem(
107+
val sys = pekko.actor.scaladsl.ActorSystem(
107108
"ActorSystemDispatchersSpec-override-internal-disp",
108109
ConfigFactory.parseString("""
109110
pekko.actor.internal-dispatcher = pekko.actor.default-dispatcher
@@ -124,7 +125,7 @@ class ActorSystemDispatchersSpec extends PekkoSpec(ConfigFactory.parseString("""
124125

125126
// using the default for internal dispatcher and passing a pre-existing execution context
126127
val system2 =
127-
ActorSystem(
128+
pekko.actor.scaladsl.ActorSystem(
128129
name = "ActorSystemDispatchersSpec-passed-in-ec-for-internal",
129130
config = Some(ConfigFactory.parseString("""
130131
pekko.actor.internal-dispatcher = pekko.actor.default-dispatcher

actor-tests/src/test/scala/org/apache/pekko/actor/CoordinatedShutdownSpec.scala

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ class CoordinatedShutdownSpec
533533
}
534534

535535
"terminate ActorSystem" in {
536-
val sys = ActorSystem(system.name, system.settings.config)
536+
val sys = pekko.actor.scaladsl.ActorSystem(system.name, system.settings.config)
537537
try {
538538
Await.result(CoordinatedShutdown(sys).run(CustomReason), 10.seconds) should ===(Done)
539539
sys.whenTerminated.isCompleted should ===(true)
@@ -544,9 +544,9 @@ class CoordinatedShutdownSpec
544544
}
545545

546546
"be run by ActorSystem.terminate" in {
547-
val sys = ActorSystem(system.name, system.settings.config)
547+
val sys = pekko.actor.scaladsl.ActorSystem(system.name, system.settings.config)
548548
try {
549-
Await.result(sys.terminate(), 10.seconds)
549+
Await.result(sys.terminateAsync(), 10.seconds)
550550
sys.whenTerminated.isCompleted should ===(true)
551551
CoordinatedShutdown(sys).shutdownReason() should ===(Some(CoordinatedShutdown.ActorSystemTerminateReason))
552552
} finally {
@@ -555,13 +555,13 @@ class CoordinatedShutdownSpec
555555
}
556556

557557
"not be run by ActorSystem.terminate when run-by-actor-system-terminate=off" in {
558-
val sys = ActorSystem(
558+
val sys = pekko.actor.scaladsl.ActorSystem(
559559
system.name,
560560
ConfigFactory
561561
.parseString("pekko.coordinated-shutdown.run-by-actor-system-terminate = off")
562562
.withFallback(system.settings.config))
563563
try {
564-
Await.result(sys.terminate(), 10.seconds)
564+
Await.result(sys.terminateAsync(), 10.seconds)
565565
sys.whenTerminated.isCompleted should ===(true)
566566
CoordinatedShutdown(sys).shutdownReason() should ===(None)
567567
} finally {
@@ -571,7 +571,7 @@ class CoordinatedShutdownSpec
571571

572572
"not allow terminate-actor-system=off && run-by-actor-system-terminate=on" in {
573573
intercept[ConfigurationException] {
574-
val sys = ActorSystem(
574+
val sys = pekko.actor.scaladsl.ActorSystem(
575575
system.name,
576576
ConfigFactory
577577
.parseString("pekko.coordinated-shutdown.terminate-actor-system = off")
@@ -659,7 +659,7 @@ class CoordinatedShutdownSpec
659659
}
660660

661661
def withCoordinatedShutdown(block: (ActorSystem, CoordinatedShutdown) => Unit): Unit = {
662-
val system = ActorSystem(
662+
val system = pekko.actor.scaladsl.ActorSystem(
663663
s"CoordinatedShutdownSpec-terminated-${System.currentTimeMillis()}",
664664
ConfigFactory.parseString("""
665665
pekko.coordinated-shutdown.phases {
@@ -761,7 +761,8 @@ class CoordinatedShutdownSpec
761761
def withSystemRunning(system: ActorSystem, cs: CoordinatedShutdown): Unit
762762

763763
private val newSystem =
764-
ActorSystem(systemName, systemConfig.withFallback(system.settings.config)).asInstanceOf[ExtendedActorSystem]
764+
pekko.actor.scaladsl.ActorSystem(systemName, systemConfig.withFallback(system.settings.config)).asInstanceOf[
765+
ExtendedActorSystem]
765766
private var shutdownHooks = Set.empty[Thread]
766767
private val mockRuntime = new JVMShutdownHooks {
767768
override def addHook(t: Thread): Unit = synchronized {

actor-tests/src/test/scala/org/apache/pekko/actor/DeployerSpec.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class DeployerSpec extends PekkoSpec(DeployerSpec.deployerConf) {
156156
ConfigParseOptions.defaults)
157157
.withFallback(PekkoSpec.testConf)
158158

159-
shutdown(ActorSystem("invalid-number-of-instances", invalidDeployerConf))
159+
shutdown(pekko.actor.scaladsl.ActorSystem("invalid-number-of-instances", invalidDeployerConf))
160160
}
161161
}
162162

@@ -175,7 +175,7 @@ class DeployerSpec extends PekkoSpec(DeployerSpec.deployerConf) {
175175
ConfigParseOptions.defaults)
176176
.withFallback(PekkoSpec.testConf)
177177

178-
shutdown(ActorSystem("invalid-path", invalidDeployerConf))
178+
shutdown(pekko.actor.scaladsl.ActorSystem("invalid-path", invalidDeployerConf))
179179
}
180180
e.getMessage should include("[ubåt]")
181181
e.getMessage should include("[/gul/ubåt]")

actor-tests/src/test/scala/org/apache/pekko/actor/DynamicAccessSpec.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
package org.apache.pekko.actor
1515

1616
import scala.collection.immutable
17-
import scala.concurrent.Await
18-
import scala.concurrent.duration._
1917
import scala.util.{ Failure, Success, Try }
2018

2119
import org.scalatest.BeforeAndAfterAll
@@ -32,7 +30,7 @@ class TestClassWithDefaultConstructor extends TestSuperclass {
3230
}
3331

3432
class DynamicAccessSpec extends AnyWordSpec with Matchers with BeforeAndAfterAll {
35-
val system = ActorSystem()
33+
val system = org.apache.pekko.actor.scaladsl.ActorSystem()
3634

3735
"The DynamicAccess of a system" should {
3836
val dynamicAccess = system.asInstanceOf[ExtendedActorSystem].dynamicAccess
@@ -88,7 +86,7 @@ class DynamicAccessSpec extends AnyWordSpec with Matchers with BeforeAndAfterAll
8886
}
8987

9088
override def afterAll() = {
91-
Await.result(system.terminate(), 10.seconds)
89+
system.close()
9290
super.afterAll()
9391
}
9492
}

actor-tests/src/test/scala/org/apache/pekko/actor/ExtensionSpec.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class ExtensionSpec extends AnyWordSpec with Matchers {
6969

7070
"support extensions" in {
7171
val config = ConfigFactory.parseString("""pekko.extensions = ["org.apache.pekko.actor.TestExtension"]""")
72-
val system = ActorSystem("extensions", config)
72+
val system = pekko.actor.scaladsl.ActorSystem("extensions", config)
7373

7474
// TestExtension is configured and should be loaded at startup
7575
system.hasExtension(TestExtension) should ===(true)
@@ -80,7 +80,7 @@ class ExtensionSpec extends AnyWordSpec with Matchers {
8080
}
8181

8282
"handle extensions that fail to initialize" in {
83-
val system = ActorSystem("extensions")
83+
val system = pekko.actor.scaladsl.ActorSystem("extensions")
8484

8585
// First attempt, an actor is created and after that
8686
// an exception is thrown:
@@ -98,7 +98,7 @@ class ExtensionSpec extends AnyWordSpec with Matchers {
9898

9999
"fail the actor system if an extension listed in pekko.extensions fails to start" in {
100100
intercept[RuntimeException] {
101-
val system = ActorSystem(
101+
val system = pekko.actor.scaladsl.ActorSystem(
102102
"failing",
103103
ConfigFactory.parseString("""
104104
pekko.extensions = ["org.apache.pekko.actor.FailingTestExtension"]
@@ -109,7 +109,7 @@ class ExtensionSpec extends AnyWordSpec with Matchers {
109109
}
110110

111111
"log an error if an extension listed in pekko.extensions cannot be loaded" in {
112-
val system = ActorSystem(
112+
val system = pekko.actor.scaladsl.ActorSystem(
113113
"failing",
114114
ConfigFactory.parseString("""
115115
pekko.extensions = ["org.apache.pekko.actor.MissingExtension"]
@@ -123,7 +123,7 @@ class ExtensionSpec extends AnyWordSpec with Matchers {
123123
import pekko.util.ccompat.JavaConverters._
124124
// could be initialized by other tests, but assuming tests are not running in parallel
125125
val countBefore = InstanceCountingExtension.createCount.get()
126-
val system = ActorSystem("extensions")
126+
val system = pekko.actor.scaladsl.ActorSystem("extensions")
127127
val listedExtensions = system.settings.config.getStringList("pekko.library-extensions").asScala
128128
listedExtensions.count(_.contains("InstanceCountingExtension")) should ===(1)
129129

@@ -136,7 +136,7 @@ class ExtensionSpec extends AnyWordSpec with Matchers {
136136
import pekko.util.ccompat.JavaConverters._
137137
// could be initialized by other tests, but assuming tests are not running in parallel
138138
val countBefore = InstanceCountingExtension.createCount.get()
139-
val system = ActorSystem(
139+
val system = pekko.actor.scaladsl.ActorSystem(
140140
"extensions",
141141
ConfigFactory.parseString(
142142
"""
@@ -152,7 +152,7 @@ class ExtensionSpec extends AnyWordSpec with Matchers {
152152

153153
"fail the actor system if a library-extension fails to start" in {
154154
intercept[FailingTestExtension.TestException] {
155-
ActorSystem(
155+
pekko.actor.scaladsl.ActorSystem(
156156
"failing",
157157
ConfigFactory.parseString("""
158158
pekko.library-extensions += "org.apache.pekko.actor.FailingTestExtension"
@@ -163,7 +163,7 @@ class ExtensionSpec extends AnyWordSpec with Matchers {
163163

164164
"fail the actor system if a library-extension cannot be loaded" in {
165165
intercept[RuntimeException] {
166-
ActorSystem(
166+
pekko.actor.scaladsl.ActorSystem(
167167
"failing",
168168
ConfigFactory.parseString("""
169169
pekko.library-extensions += "org.apache.pekko.actor.MissingExtension"

actor-tests/src/test/scala/org/apache/pekko/actor/FSMActorSpec.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ class FSMActorSpec extends PekkoSpec(Map("pekko.actor.debug.fsm" -> true)) with
264264
val config = ConfigFactory
265265
.parseMap(Map("pekko.loglevel" -> "DEBUG", "pekko.actor.debug.fsm" -> true).asJava)
266266
.withFallback(system.settings.config)
267-
val fsmEventSystem = ActorSystem("fsmEvent", config)
267+
val fsmEventSystem = pekko.actor.scaladsl.ActorSystem("fsmEvent", config)
268268
try {
269269
new TestKit(fsmEventSystem) {
270270
EventFilter.debug(occurrences = 5).intercept {
@@ -351,7 +351,7 @@ class FSMActorSpec extends PekkoSpec(Map("pekko.actor.debug.fsm" -> true)) with
351351
}
352352

353353
"allow cancelling stateTimeout by issuing forMax(Duration.Inf)" taggedAs TimingTest in {
354-
val sys = ActorSystem("fsmEvent")
354+
val sys = pekko.actor.scaladsl.ActorSystem("fsmEvent")
355355
val p = TestProbe()(sys)
356356

357357
val OverrideTimeoutToInf = "override-timeout-to-inf"

actor-tests/src/test/scala/org/apache/pekko/actor/setup/ActorSystemSetupSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class ActorSystemSetupSpec extends AnyWordSpec with Matchers {
6868
var system: ActorSystem = null
6969
try {
7070
val setup = DummySetup("Tad Moore")
71-
system = ActorSystem("name", ActorSystemSetup(setup))
71+
system = pekko.actor.scaladsl.ActorSystem("name", ActorSystemSetup(setup))
7272

7373
(system.settings.setup.get[DummySetup]: Option[Setup]) should ===(Some(setup))
7474

actor-tests/src/test/scala/org/apache/pekko/dispatch/DispatcherShutdownSpec.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import org.scalatest.matchers.should.Matchers
2222
import org.scalatest.wordspec.AnyWordSpec
2323

2424
import org.apache.pekko
25-
import pekko.actor.ActorSystem
2625
import pekko.testkit.TestKit
2726

2827
class DispatcherShutdownSpec extends AnyWordSpec with Matchers {
@@ -42,10 +41,10 @@ class DispatcherShutdownSpec extends AnyWordSpec with Matchers {
4241
"DispatcherShutdownSpec-pekko.actor.internal")) // nothing is run on default without any user actors started
4342
.size
4443

45-
val system = ActorSystem("DispatcherShutdownSpec")
44+
val system = pekko.actor.scaladsl.ActorSystem("DispatcherShutdownSpec")
4645
threadCount should be > 0
4746

48-
Await.ready(system.terminate(), 1.second)
47+
Await.ready(system.terminateAsync(), 1.second)
4948
Await.ready(Future(pekko.Done)(system.dispatcher), 1.second)
5049

5150
TestKit.awaitCond(threadCount == 0, 3.second)

actor-tests/src/test/scala/org/apache/pekko/event/AddressTerminatedTopicBenchSpec.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import scala.concurrent.duration._
1818
import org.apache.pekko
1919
import pekko.actor.Actor
2020
import pekko.actor.ActorRef
21-
import pekko.actor.ActorSystem
2221
import pekko.actor.Props
2322
import pekko.testkit._
2423

@@ -42,7 +41,7 @@ class AddressTerminatedTopicBenchSpec extends PekkoSpec("pekko.loglevel=INFO") {
4241
"Subscribe and unsubscribe of AddressTerminated" must {
4342

4443
"be quick" in {
45-
val sys = ActorSystem(system.name + "2", system.settings.config)
44+
val sys = pekko.actor.scaladsl.ActorSystem(system.name + "2", system.settings.config)
4645
try {
4746
val num = 20000
4847

0 commit comments

Comments
 (0)