Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for issue #6377 #6378

Merged
merged 5 commits into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1721,6 +1721,7 @@ namespace Akka.Actor
public bool LogDeadLettersDuringShutdown { get; }
public System.TimeSpan LogDeadLettersSuspendDuration { get; }
public string LogLevel { get; }
public bool LogSerializerOverrideOnStart { get; }
public bool LoggerAsyncStart { get; }
public System.TimeSpan LoggerStartTimeout { get; }
public System.Collections.Generic.IList<string> Loggers { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1723,6 +1723,7 @@ namespace Akka.Actor
public bool LogDeadLettersDuringShutdown { get; }
public System.TimeSpan LogDeadLettersSuspendDuration { get; }
public string LogLevel { get; }
public bool LogSerializerOverrideOnStart { get; }
public bool LoggerAsyncStart { get; }
public System.TimeSpan LoggerStartTimeout { get; }
public System.Collections.Generic.IList<string> Loggers { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1721,6 +1721,7 @@ namespace Akka.Actor
public bool LogDeadLettersDuringShutdown { get; }
public System.TimeSpan LogDeadLettersSuspendDuration { get; }
public string LogLevel { get; }
public bool LogSerializerOverrideOnStart { get; }
public bool LoggerAsyncStart { get; }
public System.TimeSpan LoggerStartTimeout { get; }
public System.Collections.Generic.IList<string> Loggers { get; }
Expand Down
1 change: 1 addition & 0 deletions src/core/Akka.Tests/Configuration/ConfigurationSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public void The_default_configuration_file_contain_all_configuration_properties(
settings.StdoutLogger.Should().NotBeNull();
settings.StdoutLogger.Should().BeOfType<StandardOutLogger>();
settings.LogConfigOnStart.ShouldBeFalse();
settings.LogSerializerOverrideOnStart.ShouldBeTrue();
settings.LogDeadLetters.ShouldBe(10);
settings.LogDeadLettersDuringShutdown.ShouldBeFalse();
settings.LogDeadLettersSuspendDuration.ShouldBe(TimeSpan.FromMinutes(5));
Expand Down
8 changes: 8 additions & 0 deletions src/core/Akka/Actor/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public Settings(ActorSystem system, Config config, ActorSystemSetup setup)

//handled
LogConfigOnStart = Config.GetBoolean("akka.log-config-on-start", false);
LogSerializerOverrideOnStart = Config.GetBoolean("akka.log-serializer-override-on-start", true);
LogDeadLetters = 0;
switch (Config.GetString("akka.log-dead-letters", null))
{
Expand Down Expand Up @@ -320,6 +321,13 @@ public Settings(ActorSystem system, Config config, ActorSystemSetup setup)
/// <value><c>true</c> if [log configuration on start]; otherwise, <c>false</c>.</value>
public bool LogConfigOnStart { get; private set; }


/// <summary>
/// Gets a value indicating whether [log serializer override on start].
/// </summary>
/// <value><c>true</c> if [log serializer override on start]; otherwise, <c>false</c>.</value>
public bool LogSerializerOverrideOnStart { get; private set; }

/// <summary>
/// Gets the log dead letters.
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions src/core/Akka/Configuration/Pigeon.conf
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ akka {
# This is useful when you are uncertain of what configuration is used.
log-config-on-start = off

# Log the serializer override notification at WARNING level when the actor system is started.
# This is useful if want to make a change of the default serializer(s) and suppress the warning
# that is created if the configuration is changed.
log-serializer-override-on-start = on

# Log at info level when messages are sent to dead letters, or published to
# eventStream as `DeadLetter`, `Dropped` or `UnhandledMessage`.
# Possible values:
Expand Down
13 changes: 9 additions & 4 deletions src/core/Akka/Serialization/Serialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ public static T WithTransport<T>(ActorSystem system, Address address, Func<T> ac
private readonly ImmutableHashSet<SerializerDetails> _serializerDetails;
private readonly MinimalLogger _initializationLogger;

private readonly bool _logSerializerOverrideOnStart;

/// <summary>
/// Serialization module. Contains methods for serialization and deserialization as well as
/// locating a Serializer for a particular class as defined in the mapping in the configuration.
Expand All @@ -165,6 +167,9 @@ public Serialization(ExtendedActorSystem system)
_nullSerializer = new NullSerializer(system);
AddSerializer("null", _nullSerializer);


_logSerializerOverrideOnStart = system.Settings.LogSerializerOverrideOnStart;

var serializersConfig = system.Settings.Config.GetConfig("akka.actor.serializers").AsEnumerable().ToList();
var serializerBindingConfig = system.Settings.Config.GetConfig("akka.actor.serialization-bindings").AsEnumerable().ToList();
var serializerSettingsConfig = system.Settings.Config.GetConfig("akka.actor.serialization-settings");
Expand Down Expand Up @@ -333,7 +338,7 @@ private Serializer GetSerializerByName(string name)
public void AddSerializer(Serializer serializer)
{
var id = serializer.Identifier;
if(_serializersById.ContainsKey(id) && _serializersById[id].GetType() != serializer.GetType())
if(_logSerializerOverrideOnStart && _serializersById.ContainsKey(id) && _serializersById[id].GetType() != serializer.GetType())
{
LogWarning(
$"Serializer with identifier [{id}] are being overriden " +
Expand All @@ -352,15 +357,15 @@ public void AddSerializer(Serializer serializer)
public void AddSerializer(string name, Serializer serializer)
{
var id = serializer.Identifier;
if(_serializersById.ContainsKey(id) && _serializersById[id].GetType() != serializer.GetType())
if(_logSerializerOverrideOnStart && _serializersById.ContainsKey(id) && _serializersById[id].GetType() != serializer.GetType())
{
LogWarning(
$"Serializer with identifier [{id}] are being overriden " +
$"from [{_serializersById[id].GetType()}] to [{serializer.GetType()}]. " +
"Did you mean to do this?");
}

if(_serializersByName.ContainsKey(name) && _serializersByName[name].GetType() != serializer.GetType())
if(_logSerializerOverrideOnStart && _serializersByName.ContainsKey(name) && _serializersByName[name].GetType() != serializer.GetType())
LogWarning(
$"Serializer with name [{serializer.Identifier}] are being overriden " +
$"from [{_serializersByName[name].GetType()}] to [{serializer.GetType()}]. " +
Expand All @@ -379,7 +384,7 @@ public void AddSerializer(string name, Serializer serializer)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void AddSerializationMap(Type type, Serializer serializer)
{
if(_serializerMap.ContainsKey(type) && _serializerMap[type].GetType() != serializer.GetType())
if(_logSerializerOverrideOnStart && _serializerMap.ContainsKey(type) && _serializerMap[type].GetType() != serializer.GetType())
LogWarning(
$"Serializer for type [{type}] are being overriden " +
$"from [{_serializerMap[type].GetType()}] to [{serializer.GetType()}]. " +
Expand Down