Skip to content

Commit 92db591

Browse files
committed
make LocalScope mean “purely local” and avoid Props serialization check, see #3210
1 parent a4af04c commit 92db591

File tree

51 files changed

+205
-117
lines changed

Some content is hidden

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

51 files changed

+205
-117
lines changed

akka-actor-tests/src/test/scala/akka/actor/DeathWatchSpec.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ trait DeathWatchSpec { this: AkkaSpec with ImplicitSender with DefaultTimeout
8787
case "ping" sender ! "pong"
8888
case t: Terminated testActor ! WrappedTerminated(t)
8989
}
90-
}))
90+
}).withDeploy(Deploy.local))
9191

9292
monitor2 ! "ping"
9393

@@ -133,7 +133,7 @@ trait DeathWatchSpec { this: AkkaSpec with ImplicitSender with DefaultTimeout
133133
super.handleFailure(context, child, cause, stats, children)
134134
}
135135
}
136-
val supervisor = system.actorOf(Props(new Supervisor(strategy)))
136+
val supervisor = system.actorOf(Props(new Supervisor(strategy)).withDeploy(Deploy.local))
137137

138138
val failed = Await.result((supervisor ? Props.empty).mapTo[ActorRef], timeout.duration)
139139
val brother = Await.result((supervisor ? Props(new Actor {
@@ -166,7 +166,7 @@ trait DeathWatchSpec { this: AkkaSpec with ImplicitSender with DefaultTimeout
166166
context unbecome
167167
}
168168
}
169-
}))
169+
}).withDeploy(Deploy.local))
170170

171171
parent ! "NKOTB"
172172
expectMsg("GREEN")
@@ -198,7 +198,7 @@ trait DeathWatchSpec { this: AkkaSpec with ImplicitSender with DefaultTimeout
198198
}
199199

200200
val t1, t2 = TestLatch()
201-
val w = system.actorOf(Props(new Watcher), "myDearWatcher")
201+
val w = system.actorOf(Props(new Watcher).withDeploy(Deploy.local), "myDearWatcher")
202202
val p = TestProbe()
203203
w ! W(p.ref)
204204
w ! ((t1, t2))

akka-actor-tests/src/test/scala/akka/io/BackpressureSpec.scala

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@ package akka.io
66

77
import java.net.InetSocketAddress
88
import java.security.MessageDigest
9-
109
import scala.concurrent.Await
1110
import scala.concurrent.duration.{ Duration, DurationInt }
1211
import scala.concurrent.forkjoin.ThreadLocalRandom
13-
1412
import akka.actor.{ Actor, ActorContext, ActorLogging, ActorRef, Props, ReceiveTimeout, Stash, Terminated }
1513
import akka.io.TcpPipelineHandler.{ Init, Management, WithinActorContext }
1614
import akka.pattern.ask
1715
import akka.testkit.{ AkkaSpec, ImplicitSender }
1816
import akka.util.{ ByteString, Timeout }
17+
import akka.actor.Deploy
1918

2019
object BackpressureSpec {
2120

@@ -38,7 +37,7 @@ object BackpressureSpec {
3837
val init = TcpPipelineHandler.withLogger(log,
3938
new TcpReadWriteAdapter >>
4039
new BackpressureBuffer(10000, 1000000, Long.MaxValue))
41-
val handler = context.actorOf(TcpPipelineHandler(init, sender, self), "pipeline")
40+
val handler = context.actorOf(TcpPipelineHandler(init, sender, self).withDeploy(Deploy.local), "pipeline")
4241
sender ! Tcp.Register(handler)
4342
unstashAll()
4443
context.become(connected(init, handler))
@@ -78,6 +77,8 @@ object BackpressureSpec {
7877
val failed: Receive = {
7978
case _ sender ! Failed
8079
}
80+
81+
override def postRestart(thr: Throwable): Unit = context.stop(self)
8182
}
8283

8384
case object GetPort
@@ -113,7 +114,7 @@ object BackpressureSpec {
113114
val init = TcpPipelineHandler.withLogger(log,
114115
new TcpReadWriteAdapter >>
115116
new BackpressureBuffer(10000, 1000000, Long.MaxValue))
116-
val handler = context.actorOf(TcpPipelineHandler(init, sender, self), "pipeline")
117+
val handler = context.actorOf(TcpPipelineHandler(init, sender, self).withDeploy(Deploy.local), "pipeline")
117118
sender ! Tcp.Register(handler)
118119
unstashAll()
119120
context.become(connected(init, handler))
@@ -147,10 +148,12 @@ object BackpressureSpec {
147148
val failed: Receive = {
148149
case _ sender ! Failed
149150
}
151+
152+
override def postRestart(thr: Throwable): Unit = context.stop(self)
150153
}
151154
}
152155

153-
class BackpressureSpec extends AkkaSpec with ImplicitSender {
156+
class BackpressureSpec extends AkkaSpec("akka.actor.serialize-creators=on") with ImplicitSender {
154157

155158
import BackpressureSpec._
156159

akka-actor-tests/src/test/scala/akka/io/CapacityLimitSpec.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ import Tcp._
99
import akka.TestUtils
1010
import TestUtils._
1111

12-
class CapacityLimitSpec extends AkkaSpec("akka.loglevel = ERROR\nakka.io.tcp.max-channels = 4")
12+
class CapacityLimitSpec extends AkkaSpec("""
13+
akka.loglevel = ERROR
14+
akka.io.tcp.max-channels = 4
15+
akka.actor.serialize-creators = on
16+
""")
1317
with TcpIntegrationSpecSupport {
1418

1519
"The TCP transport implementation" should {

akka-actor-tests/src/test/scala/akka/io/DelimiterFramingSpec.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ import java.util.concurrent.atomic.AtomicInteger
1212
import scala.concurrent.duration._
1313
import akka.io.TcpPipelineHandler.Management
1414
import akka.actor.ActorRef
15+
import akka.actor.Deploy
1516

16-
class DelimiterFramingSpec extends AkkaSpec {
17+
class DelimiterFramingSpec extends AkkaSpec("akka.actor.serialize-creators = on") {
1718

1819
val addresses = TestUtils.temporaryServerAddresses(4)
1920

@@ -40,7 +41,7 @@ class DelimiterFramingSpec extends AkkaSpec {
4041
val counter = new AtomicInteger
4142

4243
def testSetup(serverAddress: InetSocketAddress, delimiter: String, includeDelimiter: Boolean): Unit = {
43-
val bindHandler = system.actorOf(Props(classOf[AkkaLineEchoServer], this, delimiter, includeDelimiter))
44+
val bindHandler = system.actorOf(Props(classOf[AkkaLineEchoServer], this, delimiter, includeDelimiter).withDeploy(Deploy.local))
4445
val probe = TestProbe()
4546
probe.send(IO(Tcp), Tcp.Bind(bindHandler, serverAddress))
4647
probe.expectMsgType[Tcp.Bound]
@@ -68,7 +69,7 @@ class DelimiterFramingSpec extends AkkaSpec {
6869

6970
import init._
7071

71-
val handler = system.actorOf(TcpPipelineHandler(init, connection, probe.ref),
72+
val handler = system.actorOf(TcpPipelineHandler(init, connection, probe.ref).withDeploy(Deploy.local),
7273
"client" + counter.incrementAndGet())
7374
probe.send(connection, Tcp.Register(handler))
7475

@@ -128,7 +129,7 @@ class DelimiterFramingSpec extends AkkaSpec {
128129
import init._
129130

130131
val connection = sender
131-
val handler = context.actorOf(TcpPipelineHandler(init, sender, self), "pipeline")
132+
val handler = context.actorOf(TcpPipelineHandler(init, sender, self).withDeploy(Deploy.local), "pipeline")
132133

133134
connection ! Tcp.Register(handler)
134135

akka-actor-tests/src/test/scala/akka/io/PipelineSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import scala.concurrent.forkjoin.ThreadLocalRandom
1212
import scala.util.Try
1313
import scala.util.Success
1414

15-
class PipelineSpec extends AkkaSpec {
15+
class PipelineSpec extends AkkaSpec("akka.actor.serialize-creators = on") {
1616

1717
trait Level1
1818
trait Level2

akka-actor-tests/src/test/scala/akka/io/TcpConnectionSpec.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ import akka.testkit.{ AkkaSpec, EventFilter, TestActorRef, TestProbe }
2323
import akka.util.{ Helpers, ByteString }
2424
import akka.TestUtils._
2525

26-
class TcpConnectionSpec extends AkkaSpec("akka.io.tcp.register-timeout = 500ms") {
26+
class TcpConnectionSpec extends AkkaSpec("""
27+
akka.io.tcp.register-timeout = 500ms
28+
akka.actor.serialize-creators = on
29+
""") {
2730
// Helper to avoid Windows localization specific differences
2831
def ignoreIfWindows(): Unit =
2932
if (Helpers.isWindows) {

akka-actor-tests/src/test/scala/akka/io/TcpIntegrationSpec.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ import TestUtils._
1212
import akka.testkit.EventFilter
1313
import java.io.IOException
1414

15-
class TcpIntegrationSpec extends AkkaSpec("akka.loglevel = INFO") with TcpIntegrationSpecSupport {
15+
class TcpIntegrationSpec extends AkkaSpec("""
16+
akka.loglevel = INFO
17+
akka.actor.serialize-creators = on
18+
""") with TcpIntegrationSpecSupport {
1619

1720
"The TCP transport implementation" should {
1821

akka-actor-tests/src/test/scala/akka/io/TcpListenerSpec.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ import akka.io.SelectionHandler._
1515
import akka.TestUtils
1616
import Tcp._
1717

18-
class TcpListenerSpec extends AkkaSpec("akka.io.tcp.batch-accept-limit = 2") {
18+
class TcpListenerSpec extends AkkaSpec("""
19+
akka.io.tcp.batch-accept-limit = 2
20+
akka.actor.serialize-creators = on
21+
""") {
1922

2023
"A TcpListener" must {
2124

@@ -130,7 +133,7 @@ class TcpListenerSpec extends AkkaSpec("akka.io.tcp.batch-accept-limit = 2") {
130133
private class ListenerParent extends Actor with ChannelRegistry {
131134
val listener = context.actorOf(
132135
props = Props(classOf[TcpListener], selectorRouter.ref, Tcp(system), this, bindCommander.ref,
133-
Bind(handler.ref, endpoint, 100, Nil)),
136+
Bind(handler.ref, endpoint, 100, Nil)).withDeploy(Deploy.local),
134137
name = "test-listener-" + counter.next())
135138
parent.watch(listener)
136139
def receive: Receive = {

akka-actor-tests/src/test/scala/akka/io/UdpConnectedIntegrationSpec.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ import akka.util.ByteString
1010
import java.net.InetSocketAddress
1111
import akka.actor.ActorRef
1212

13-
class UdpConnectedIntegrationSpec extends AkkaSpec("akka.loglevel = INFO") with ImplicitSender {
13+
class UdpConnectedIntegrationSpec extends AkkaSpec("""
14+
akka.loglevel = INFO
15+
akka.actor.serialize-creators = on
16+
""") with ImplicitSender {
1417

1518
val addresses = temporaryServerAddresses(3, udp = true)
1619

akka-actor-tests/src/test/scala/akka/io/UdpIntegrationSpec.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import akka.util.ByteString
1010
import java.net.InetSocketAddress
1111
import akka.actor.ActorRef
1212

13-
class UdpIntegrationSpec extends AkkaSpec("akka.loglevel = INFO") with ImplicitSender {
13+
class UdpIntegrationSpec extends AkkaSpec("""
14+
akka.loglevel = INFO
15+
akka.actor.serialize-creators = on""") with ImplicitSender {
1416

1517
val addresses = temporaryServerAddresses(3, udp = true)
1618

0 commit comments

Comments
 (0)