Skip to content

Commit

Permalink
Change PrimitiveSerializer compatibility switch setting name from `us…
Browse files Browse the repository at this point in the history
…e-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 <aaron@petabridge.com>
(cherry picked from commit 302e3cb)
  • Loading branch information
Arkatufus committed May 2, 2024
1 parent b03eec7 commit ff6a86d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/core/Akka.Remote.Tests/RemoteConfigSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/Akka.Remote.Tests/Serialization/BugFix5279Spec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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());
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka.Remote/Configuration/Remote.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ akka {
actor {
serialization-settings {
primitive {
use-neutral-primitives = off
use-legacy-behavior = on
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/core/Akka.Remote/Serialization/PrimitiveSerializers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/// <summary>
/// Initializes a new instance of the <see cref="PrimitiveSerializers" /> class.
/// </summary>
/// <param name="system">The actor system to associate with this serializer. </param>
/// <param name="config">Config object containing the serializer settings</param>
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");
}

/// <inheritdoc />
Expand Down Expand Up @@ -85,7 +86,7 @@ public override object FromBinary(byte[] bytes, string manifest)
/// <inheritdoc />
public override string Manifest(object obj)
{
if (_useNeutralPrimitives)
if (_useLegacyBehavior)
return obj.GetType().TypeQualifiedName();

switch (obj)
Expand Down

0 comments on commit ff6a86d

Please sign in to comment.