Skip to content

Commit 3c2525a

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

File tree

84 files changed

+558
-204
lines changed

Some content is hidden

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

84 files changed

+558
-204
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: 1 addition & 3 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
@@ -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/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

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class EventStreamSpec extends PekkoSpec(EventStreamSpec.config) {
113113
}
114114

115115
"be able to log unhandled messages" in {
116-
val sys = ActorSystem("EventStreamSpecUnhandled", configUnhandled)
116+
val sys = pekko.actor.scaladsl.ActorSystem("EventStreamSpecUnhandled", configUnhandled)
117117
try {
118118
sys.eventStream.subscribe(testActor, classOf[AnyRef])
119119
val m = UnhandledMessage(42, sys.deadLetters, sys.deadLetters)
@@ -296,7 +296,7 @@ class EventStreamSpec extends PekkoSpec(EventStreamSpec.config) {
296296
}
297297

298298
"unsubscribe an actor on its termination" in {
299-
val sys = ActorSystem("EventStreamSpecUnsubscribeOnTerminated", configUnhandledWithDebug)
299+
val sys = pekko.actor.scaladsl.ActorSystem("EventStreamSpecUnsubscribeOnTerminated", configUnhandledWithDebug)
300300

301301
try {
302302
val es = sys.eventStream
@@ -325,7 +325,7 @@ class EventStreamSpec extends PekkoSpec(EventStreamSpec.config) {
325325
}
326326

327327
"unsubscribe the actor, when it subscribes already in terminated state" in {
328-
val sys = ActorSystem("EventStreamSpecUnsubscribeTerminated", configUnhandledWithDebug)
328+
val sys = pekko.actor.scaladsl.ActorSystem("EventStreamSpecUnsubscribeTerminated", configUnhandledWithDebug)
329329

330330
try {
331331
val es = sys.eventStream
@@ -356,7 +356,7 @@ class EventStreamSpec extends PekkoSpec(EventStreamSpec.config) {
356356
}
357357

358358
"not allow initializing a TerminatedUnsubscriber twice" in {
359-
val sys = ActorSystem("MustNotAllowDoubleInitOfTerminatedUnsubscriber")
359+
val sys = pekko.actor.scaladsl.ActorSystem("MustNotAllowDoubleInitOfTerminatedUnsubscriber")
360360
// initializes an TerminatedUnsubscriber during start
361361

362362
try {
@@ -373,7 +373,7 @@ class EventStreamSpec extends PekkoSpec(EventStreamSpec.config) {
373373
}
374374

375375
"unwatch an actor from unsubscriber when that actor unsubscribes from the stream" in {
376-
val sys = ActorSystem("MustUnregisterDuringUnsubscribe", configUnhandledWithDebug)
376+
val sys = pekko.actor.scaladsl.ActorSystem("MustUnregisterDuringUnsubscribe", configUnhandledWithDebug)
377377

378378
try {
379379
val es = sys.eventStream
@@ -393,7 +393,8 @@ class EventStreamSpec extends PekkoSpec(EventStreamSpec.config) {
393393
}
394394

395395
"unwatch an actor from unsubscriber when that actor unsubscribes from channels it subscribed" in {
396-
val sys = ActorSystem("MustUnregisterWhenNoMoreChannelSubscriptions", configUnhandledWithDebug)
396+
val sys =
397+
pekko.actor.scaladsl.ActorSystem("MustUnregisterWhenNoMoreChannelSubscriptions", configUnhandledWithDebug)
397398

398399
try {
399400
val es = sys.eventStream

0 commit comments

Comments
 (0)