From 302e3cbe9d6d8315be0856f0ca8fab793ebde39b Mon Sep 17 00:00:00 2001 From: Gregorius Soedharmo Date: Wed, 29 Sep 2021 03:04:18 +0700 Subject: [PATCH] Change PrimitiveSerializer compatibility switch setting name from `use-neutral-primitives` to `use-legacy-behavior` for less ambiguity (#5290) * Change PrimitiveSerializer compatibility switch setting name from `use-neutral-primitives` to `use-legacy-behavior` for less ambiguity * Fix unit test * Change default to full compatibility (on) * Fix unit test Co-authored-by: Aaron Stannard --- src/core/Akka.Remote.Tests/RemoteConfigSpec.cs | 2 +- src/core/Akka.Remote.Tests/Serialization/BugFix5279Spec.cs | 4 ++-- src/core/Akka.Remote/Configuration/Remote.conf | 2 +- src/core/Akka.Remote/Serialization/PrimitiveSerializers.cs | 7 ++++--- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/core/Akka.Remote.Tests/RemoteConfigSpec.cs b/src/core/Akka.Remote.Tests/RemoteConfigSpec.cs index 2ccf1ff54da..76c5312dcb0 100644 --- a/src/core/Akka.Remote.Tests/RemoteConfigSpec.cs +++ b/src/core/Akka.Remote.Tests/RemoteConfigSpec.cs @@ -182,7 +182,7 @@ public void Remoting_should_contain_correct_PrimitiveSerializer_settings_in_Refe { var c = RARP.For(Sys).Provider.RemoteSettings.Config.GetConfig("akka.actor.serialization-settings.primitive"); c.Should().NotBeNull(); - c.GetBoolean("use-neutral-primitives").Should().BeFalse(); + c.GetBoolean("use-legacy-behavior").Should().BeTrue(); } } } diff --git a/src/core/Akka.Remote.Tests/Serialization/BugFix5279Spec.cs b/src/core/Akka.Remote.Tests/Serialization/BugFix5279Spec.cs index e026d11cbb8..7f2aca1f329 100644 --- a/src/core/Akka.Remote.Tests/Serialization/BugFix5279Spec.cs +++ b/src/core/Akka.Remote.Tests/Serialization/BugFix5279Spec.cs @@ -23,7 +23,7 @@ public class BugFix5279Spec: AkkaSpec [InlineData("1", "S")] public void PrimitiveSerializer_without_useNeutralPrimitives_should_return_custom_manifest(object data, string manifest) { - var config = ConfigurationFactory.ParseString("use-neutral-primitives = off"); + var config = ConfigurationFactory.ParseString("use-legacy-behavior = off"); var serializer = new PrimitiveSerializers((ExtendedActorSystem)Sys, config); serializer.Manifest(data).Should().Be(manifest); } @@ -34,7 +34,7 @@ public void PrimitiveSerializer_without_useNeutralPrimitives_should_return_custo [InlineData("1")] public void PrimitiveSerializer_without_useNeutralPrimitives_should_return_type_manifest(object data) { - var config = ConfigurationFactory.ParseString("use-neutral-primitives = on"); + var config = ConfigurationFactory.ParseString("use-legacy-behavior = on"); var serializer = new PrimitiveSerializers((ExtendedActorSystem)Sys, config); serializer.Manifest(data).Should().Be(data.GetType().TypeQualifiedName()); } diff --git a/src/core/Akka.Remote/Configuration/Remote.conf b/src/core/Akka.Remote/Configuration/Remote.conf index ce6ae49b152..ac304154e5f 100644 --- a/src/core/Akka.Remote/Configuration/Remote.conf +++ b/src/core/Akka.Remote/Configuration/Remote.conf @@ -12,7 +12,7 @@ akka { actor { serialization-settings { primitive { - use-neutral-primitives = off + use-legacy-behavior = on } } diff --git a/src/core/Akka.Remote/Serialization/PrimitiveSerializers.cs b/src/core/Akka.Remote/Serialization/PrimitiveSerializers.cs index 65713531ba6..8f6501c1e14 100644 --- a/src/core/Akka.Remote/Serialization/PrimitiveSerializers.cs +++ b/src/core/Akka.Remote/Serialization/PrimitiveSerializers.cs @@ -30,18 +30,19 @@ public sealed class PrimitiveSerializers : SerializerWithStringManifest internal const string Int32ManifestNetFx = "System.Int32, mscorlib"; internal const string Int64ManifestNetFx = "System.Int64, mscorlib"; - private readonly bool _useNeutralPrimitives; + private readonly bool _useLegacyBehavior; /// /// Initializes a new instance of the class. /// /// The actor system to associate with this serializer. + /// Config object containing the serializer settings public PrimitiveSerializers(ExtendedActorSystem system, Config config) : base(system) { if (config == null) throw new ConfigurationException("configuration is null"); - _useNeutralPrimitives = config.GetBoolean("use-neutral-primitives"); + _useLegacyBehavior = config.GetBoolean("use-legacy-behavior"); } /// @@ -85,7 +86,7 @@ public override object FromBinary(byte[] bytes, string manifest) /// public override string Manifest(object obj) { - if (_useNeutralPrimitives) + if (_useLegacyBehavior) return obj.GetType().TypeQualifiedName(); switch (obj)