Skip to content

Commit

Permalink
use some compound statements (#6814)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Jun 27, 2023
1 parent abae81c commit b5ac7ef
Show file tree
Hide file tree
Showing 31 changed files with 41 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public PingPongActor()
}

private ILoggingAdapter _log;
private ILoggingAdapter Log => _log ?? (_log = Context.GetLogger());
private ILoggingAdapter Log => _log ??= Context.GetLogger();

protected override bool Receive(object message)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public Home(Address address)
};

private ILoggingAdapter _log;
private ILoggingAdapter Log => _log ?? (_log = Context.GetLogger());
private ILoggingAdapter Log => _log ??= Context.GetLogger();

private Address SelfAddress => Cluster.Get(Context.System).SelfAddress;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1488,7 +1488,7 @@ public static Props Props(
private readonly bool _isRebalance;
private ILoggingAdapter _log;

private ILoggingAdapter Log { get { return _log ?? (_log = Context.GetLogger()); } }
private ILoggingAdapter Log { get { return _log ??= Context.GetLogger(); } }

public ITimerScheduler Timers { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public static Props Props(DistributedPubSubSettings settings)
/// <summary>
/// TBD
/// </summary>
public ILoggingAdapter Log { get { return _log ?? (_log = Context.GetLogger()); } }
public ILoggingAdapter Log { get { return _log ??= Context.GetLogger(); } }

/// <summary>
/// TBD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public ValueHolder(long version, IActorRef @ref)
/// <summary>
/// TBD
/// </summary>
public Routee Routee { get { return _routee ?? (_routee = Ref != null ? new ActorRefRoutee(Ref) : null); } }
public Routee Routee { get { return _routee ??= Ref != null ? new ActorRefRoutee(Ref) : null; } }

/// <inheritdoc/>
public bool Equals(ValueHolder other)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ private void SetupCoordinatedShutdown()
});
}

private ILoggingAdapter Log { get { return _log ?? (_log = Context.GetLogger()); } }
private ILoggingAdapter Log { get { return _log ??= Context.GetLogger(); } }

/// <inheritdoc cref="ActorBase.PreStart"/>
protected override void PreStart()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public ClusterSingletonProxy(string singletonManagerPath, ClusterSingletonProxyS
});
}

private ILoggingAdapter Log => _log ?? (_log = Context.GetLogger());
private ILoggingAdapter Log => _log ??= Context.GetLogger();

/// <summary>
/// TBD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private SendToSecondary() { }

private ILoggingAdapter _log;

protected ILoggingAdapter Log => _log ?? (_log = Context.GetLogger());
protected ILoggingAdapter Log => _log ??= Context.GetLogger();

protected abstract int DoneWhenRemainingSize { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected AbstractAllEventsPublisher(int fromOffset, int maxBufferSize, string w
JournalRef = Persistence.Instance.Apply(Context.System).JournalFor(writeJournalPluginId);
}

protected ILoggingAdapter Log => _log ?? (_log = Context.GetLogger());
protected ILoggingAdapter Log => _log ??= Context.GetLogger();
protected IActorRef JournalRef { get; }
protected DeliveryBuffer<EventEnvelope> Buffer { get; }
protected int FromOffset { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected AbstractEventsByPersistenceIdPublisher(string persistenceId, long from
JournalRef = Persistence.Instance.Apply(Context.System).JournalFor(writeJournalPluginId);
}

protected ILoggingAdapter Log => _log ?? (_log = Context.GetLogger());
protected ILoggingAdapter Log => _log ??= Context.GetLogger();
protected string PersistenceId { get; }
protected long FromSequenceNr { get; }
protected long ToSequenceNr { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected AbstractEventsByTagPublisher(string tag, int fromOffset, int maxBuffer
JournalRef = Persistence.Instance.Apply(Context.System).JournalFor(writeJournalPluginId);
}

protected ILoggingAdapter Log => _log ?? (_log = Context.GetLogger());
protected ILoggingAdapter Log => _log ??= Context.GetLogger();
protected string Tag { get; }
protected int FromOffset { get; }
protected abstract int ToOffset { get; }
Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka.Cluster/SBR/SplitBrainResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected SplitBrainResolverBase(TimeSpan stableAfter, DowningStrategy strategy)

public DowningStrategy Strategy { get; }

public ILoggingAdapter Log => _log ?? (_log = Context.GetLogger());
public ILoggingAdapter Log => _log ??= Context.GetLogger();

public abstract UniqueAddress SelfUniqueAddress { get; }

Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka.Cluster/SplitBrainResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public SplitBrainDecider(TimeSpan stableAfter, ISplitBrainStrategy strategy, Clu
_cluster = cluster;
}

public ILoggingAdapter Log => _log ?? (_log = Context.GetLogger());
public ILoggingAdapter Log => _log ??= Context.GetLogger();

protected override void PreStart()
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka.Coordination/LeaseProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static LeaseProvider Get(ActorSystem system)

private ILoggingAdapter _log;

private ILoggingAdapter Log { get { return _log ?? (_log = Logging.GetLogger(_system, "LeaseProvider")); } }
private ILoggingAdapter Log { get { return _log ??= Logging.GetLogger(_system, "LeaseProvider"); } }

/// <summary>
/// Initializes a new instance of the <see cref="LeaseProvider"/> class.
Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka.Persistence.Query/PersistenceQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static PersistenceQuery Get(ActorSystem system)
return system.WithExtension<PersistenceQuery, PersistenceQueryProvider>();
}

public ILoggingAdapter Log => _log ?? (_log = _system.Log);
public ILoggingAdapter Log => _log ??= _system.Log;

public PersistenceQuery(ExtendedActorSystem system)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ internal class CrashingActor : AtLeastOnceDeliveryActor
private readonly IActorRef _testProbe;
private ILoggingAdapter _adapter;

ILoggingAdapter Log { get { return _adapter ?? (_adapter = Context.GetLogger()); } }
ILoggingAdapter Log { get { return _adapter ??= Context.GetLogger(); } }

public CrashingActor(IActorRef testProbe)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ internal class ChaosSender : AtLeastOnceDeliveryActor
private readonly double _replayProcessingFailureRate;
private ILoggingAdapter _log;

public ILoggingAdapter Log { get { return _log ?? (_log = Context.GetLogger()); }}
public ILoggingAdapter Log { get { return _log ??= Context.GetLogger(); }}

public ChaosSender(IActorRef destination, IActorRef probe)
: base(x => x.WithRedeliverInterval(TimeSpan.FromMilliseconds(500)))
Expand Down Expand Up @@ -242,7 +242,7 @@ internal class ChaosDestination : ReceiveActor, IChaosSupport
private readonly double _confirmFailureRate;
private ILoggingAdapter _log;

public ILoggingAdapter Log { get { return _log ?? (_log = Context.GetLogger()); } }
public ILoggingAdapter Log { get { return _log ??= Context.GetLogger(); } }

public ChaosDestination(IActorRef probe)
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka.Persistence/Fsm/PersistentFSMBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ private StateFunction HandleEventDefault

private StateFunction HandleEvent
{
get { return _handleEvent ?? (_handleEvent = HandleEventDefault); }
get { return _handleEvent ??= HandleEventDefault; }
set { _handleEvent = value; }
}

Expand Down
6 changes: 2 additions & 4 deletions src/core/Akka.Remote/Transport/AkkaProtocolTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,8 @@ protected override Props ManagerProps
{
get
{
return _managerProps ??
(_managerProps =
Props.Create(() => new AkkaProtocolManager(WrappedTransport, Settings))
.WithDeploy(Deploy.Local));
return _managerProps ??= Props.Create(() => new AkkaProtocolManager(WrappedTransport, Settings))
.WithDeploy(Deploy.Local);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka.Streams/Implementation/ActorProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ protected ActorProcessorImpl(ActorMaterializerSettings settings)
/// <summary>
/// TBD
/// </summary>
protected ILoggingAdapter Log => _log ?? (_log = Context.GetLogger());
protected ILoggingAdapter Log => _log ??= Context.GetLogger();

/// <summary>
/// TBD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public ActorRefSourceActor(int bufferSize, OverflowStrategy overflowStrategy, in
/// <summary>
/// TBD
/// </summary>
protected ILoggingAdapter Log => _log ?? (_log = Context.GetLogger());
protected ILoggingAdapter Log => _log ??= Context.GetLogger();

/// <summary>
/// TBD
Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka.Streams/Implementation/FanIn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ protected FanIn(ActorMaterializerSettings settings, int inputCount)
/// <summary>
/// TBD
/// </summary>
protected ILoggingAdapter Log => _log ?? (_log = Context.GetLogger());
protected ILoggingAdapter Log => _log ??= Context.GetLogger();
private ILoggingAdapter _log;

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka.Streams/Implementation/FanOut.cs
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ protected FanOut(ActorMaterializerSettings settings, int outputCount)
/// <summary>
/// TBD
/// </summary>
protected ILoggingAdapter Log => _log ?? (_log = Context.GetLogger());
protected ILoggingAdapter Log => _log ??= Context.GetLogger();
private ILoggingAdapter _log;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,11 @@ public GraphInterpreterShell(GraphAssembly assembly, Connection[] connections, G
/// <summary>
/// TBD
/// </summary>
public ILoggingAdapter Log => _log ?? (_log = GetLogger());
public ILoggingAdapter Log => _log ??= GetLogger();
/// <summary>
/// TBD
/// </summary>
public GraphInterpreter Interpreter => _interpreter ?? (_interpreter = GetInterpreter());
public GraphInterpreter Interpreter => _interpreter ??= GetInterpreter();

/// <summary>
/// TBD
Expand Down Expand Up @@ -1358,7 +1358,7 @@ public ActorGraphInterpreter(GraphInterpreterShell shell)
/// <summary>
/// TBD
/// </summary>
public ILoggingAdapter Log => _log ?? (_log = Context.GetLogger());
public ILoggingAdapter Log => _log ??= Context.GetLogger();

private void EnqueueToShortCircuit(object input)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ private string QueueStatus()
/// <summary>
/// TBD
/// </summary>
internal string Name => _name ?? (_name = GetHashCode().ToString("x"));
internal string Name => _name ??= GetHashCode().ToString("x");

/// <summary>
/// Assign the boundary logic to a given connection. This will serve as the interface to the external world
Expand Down
9 changes: 4 additions & 5 deletions src/core/Akka.Streams/Implementation/StreamRef/SinkRefImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,10 @@ private sealed class Logic : TimerGraphStageLogic, IInHandler
private StreamRefAttributes.SubscriptionTimeout _subscriptionTimeout;
private string _stageActorName;

private StreamRefsMaster StreamRefsMaster => _streamRefsMaster ?? (_streamRefsMaster = StreamRefsMaster.Get(ActorMaterializerHelper.Downcast(Materializer).System));
private StreamRefSettings Settings => _settings ?? (_settings = ActorMaterializerHelper.Downcast(Materializer).Settings.StreamRefSettings);
private StreamRefAttributes.SubscriptionTimeout SubscriptionTimeout => _subscriptionTimeout ?? (_subscriptionTimeout =
_inheritedAttributes.GetAttribute(new StreamRefAttributes.SubscriptionTimeout(Settings.SubscriptionTimeout)));
protected override string StageActorName => _stageActorName ?? (_stageActorName = StreamRefsMaster.NextSinkRefName());
private StreamRefsMaster StreamRefsMaster => _streamRefsMaster ??= StreamRefsMaster.Get(ActorMaterializerHelper.Downcast(Materializer).System);
private StreamRefSettings Settings => _settings ??= ActorMaterializerHelper.Downcast(Materializer).Settings.StreamRefSettings;
private StreamRefAttributes.SubscriptionTimeout SubscriptionTimeout => _subscriptionTimeout ??= _inheritedAttributes.GetAttribute(new StreamRefAttributes.SubscriptionTimeout(Settings.SubscriptionTimeout));
protected override string StageActorName => _stageActorName ??= StreamRefsMaster.NextSinkRefName();

private StageActor _stageActor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,10 @@ private sealed class Logic : TimerGraphStageLogic, IOutHandler
private StageActor _stageActor;
private IActorRef _partnerRef = null;

private StreamRefsMaster StreamRefsMaster => _streamRefsMaster ?? (_streamRefsMaster = StreamRefsMaster.Get(ActorMaterializerHelper.Downcast(Materializer).System));
private StreamRefSettings Settings => _settings ?? (_settings = ActorMaterializerHelper.Downcast(Materializer).Settings.StreamRefSettings);
private StreamRefAttributes.SubscriptionTimeout SubscriptionTimeout => _subscriptionTimeout ?? (_subscriptionTimeout =
_inheritedAttributes.GetAttribute(new StreamRefAttributes.SubscriptionTimeout(Settings.SubscriptionTimeout)));
protected override string StageActorName => _stageActorName ?? (_stageActorName = StreamRefsMaster.NextSourceRefName());
private StreamRefsMaster StreamRefsMaster => _streamRefsMaster ??= StreamRefsMaster.Get(ActorMaterializerHelper.Downcast(Materializer).System);
private StreamRefSettings Settings => _settings ??= ActorMaterializerHelper.Downcast(Materializer).Settings.StreamRefSettings;
private StreamRefAttributes.SubscriptionTimeout SubscriptionTimeout => _subscriptionTimeout ??= _inheritedAttributes.GetAttribute(new StreamRefAttributes.SubscriptionTimeout(Settings.SubscriptionTimeout));
protected override string StageActorName => _stageActorName ??= StreamRefsMaster.NextSourceRefName();

public IActorRef Self => _stageActor.Ref;
public IActorRef PartnerRef
Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka/Actor/ActorBase.SupervisorStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public abstract partial class ActorBase
/// </summary>
internal SupervisorStrategy SupervisorStrategyInternal
{
get { return _supervisorStrategy ?? (_supervisorStrategy = SupervisorStrategy()); }
get { return _supervisorStrategy ??= SupervisorStrategy(); }
set { _supervisorStrategy = value; }
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka/Actor/FSM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@ private StateFunction HandleEventDefault

private StateFunction HandleEvent
{
get { return _handleEvent ?? (_handleEvent = HandleEventDefault); }
get { return _handleEvent ??= HandleEventDefault; }
set { _handleEvent = value; }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class AkkaConfigurationSection : ConfigurationSection
/// </summary>
public Config AkkaConfig
{
get { return _akkaConfig ?? (_akkaConfig = ConfigurationFactory.ParseString(Hocon.Content)); }
get { return _akkaConfig ??= ConfigurationFactory.ParseString(Hocon.Content); }
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka/Routing/ConsistentHash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public ConsistentHash(SortedDictionary<int, T> nodes, int virtualNodesFactor)
private (int[], T[])? _ring = null;
private (int[], T[])? RingTuple
{
get { return _ring ?? (_ring = (_nodes.Keys.ToArray(), _nodes.Values.ToArray())); }
get { return _ring ??= (_nodes.Keys.ToArray(), _nodes.Values.ToArray()); }
}

private int[] NodeHashRing
Expand Down

0 comments on commit b5ac7ef

Please sign in to comment.