Make sure Serialization.currentTransportInformation is always set, #25067
* The ThreadLocal Serialization.currentTransportInformation is used for serializing local actor refs, but it's also useful when a serializer library e.g. custom serializer/deserializer in Jackson need access to the current ActorSystem. * We set this in a rather ad-hoc way from remoting and in some persistence plugins, but it's only set for serialization and not deserialization, and it's easy for Persistence plugins or other libraries to forget this when using Akka serialization directly. * This change is automatically setting the info when using the ordinary serialize and deserialize methods. * It's also set when LocalActorRefProvider, which wasn't always the case previously. * Keep a cached instance of Serialization.Information in the provider to avoid creating new instances all the time. * Added optional Persistence TCK tests to verify that the plugin is setting this if it's using some custom calls to the serializer.
This commit is contained in:
parent
6ec46e762f
commit
e6633f17fa
36 changed files with 579 additions and 146 deletions
|
|
@ -149,11 +149,14 @@ trait SerializationSupport {
|
|||
|
||||
// Serialize actor references with full address information (defaultAddress).
|
||||
// When sending remote messages currentTransportInformation is already set,
|
||||
// but when serializing for digests it must be set here.
|
||||
if (Serialization.currentTransportInformation.value == null)
|
||||
Serialization.currentTransportInformation.withValue(transportInformation) { buildOther() }
|
||||
else
|
||||
// but when serializing for digests or DurableStore it must be set here.
|
||||
val oldInfo = Serialization.currentTransportInformation.value
|
||||
try {
|
||||
if (oldInfo eq null)
|
||||
Serialization.currentTransportInformation.value = system.provider.serializationInformation
|
||||
buildOther()
|
||||
} finally Serialization.currentTransportInformation.value = oldInfo
|
||||
|
||||
}
|
||||
|
||||
def otherMessageFromBinary(bytes: Array[Byte]): AnyRef =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue