From b5ac7efdf1ed1a73d6b72e899ecd8f0a6afbf849 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Wed, 28 Jun 2023 02:09:28 +1000 Subject: [PATCH] use some compound statements (#6814) --- .../MultiNodeClusterShardingSpec.cs | 2 +- .../RollingUpdateShardAllocationSpec.cs | 2 +- .../cluster/Akka.Cluster.Sharding/ShardCoordinator.cs | 2 +- .../PublishSubscribe/DistributedPubSubMediator.cs | 2 +- .../PublishSubscribe/Internal/TopicMessages.cs | 2 +- .../Singleton/ClusterSingletonManager.cs | 2 +- .../Singleton/ClusterSingletonProxy.cs | 2 +- .../cluster/Akka.DistributedData/ReadWriteAggregator.cs | 2 +- .../AllEventsPublisher.cs | 2 +- .../EventsByPersistenceIdPublisher.cs | 2 +- .../EventsByTagPublisher.cs | 2 +- src/core/Akka.Cluster/SBR/SplitBrainResolver.cs | 2 +- src/core/Akka.Cluster/SplitBrainResolver.cs | 2 +- src/core/Akka.Coordination/LeaseProvider.cs | 2 +- src/core/Akka.Persistence.Query/PersistenceQuery.cs | 2 +- .../AtLeastOnceDeliveryCrashSpec.cs | 2 +- .../AtLeastOnceDeliveryFailureSpec.cs | 4 ++-- src/core/Akka.Persistence/Fsm/PersistentFSMBase.cs | 2 +- src/core/Akka.Remote/Transport/AkkaProtocolTransport.cs | 6 ++---- src/core/Akka.Streams/Implementation/ActorProcessor.cs | 2 +- .../Akka.Streams/Implementation/ActorRefSourceActor.cs | 2 +- src/core/Akka.Streams/Implementation/FanIn.cs | 2 +- src/core/Akka.Streams/Implementation/FanOut.cs | 2 +- .../Implementation/Fusing/ActorGraphInterpreter.cs | 6 +++--- .../Implementation/Fusing/GraphInterpreter.cs | 2 +- .../Akka.Streams/Implementation/StreamRef/SinkRefImpl.cs | 9 ++++----- .../Implementation/StreamRef/SourceRefImpl.cs | 9 ++++----- src/core/Akka/Actor/ActorBase.SupervisorStrategy.cs | 2 +- src/core/Akka/Actor/FSM.cs | 2 +- .../Akka/Configuration/Hocon/AkkaConfigurationSection.cs | 2 +- src/core/Akka/Routing/ConsistentHash.cs | 2 +- 31 files changed, 41 insertions(+), 45 deletions(-) diff --git a/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/MultiNodeClusterShardingSpec.cs b/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/MultiNodeClusterShardingSpec.cs index 96095a0d38c..3e10524962e 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/MultiNodeClusterShardingSpec.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/MultiNodeClusterShardingSpec.cs @@ -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) { diff --git a/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/RollingUpdateShardAllocationSpec.cs b/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/RollingUpdateShardAllocationSpec.cs index 9e87bdb2572..e7b57c227d7 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/RollingUpdateShardAllocationSpec.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/RollingUpdateShardAllocationSpec.cs @@ -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; diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/ShardCoordinator.cs b/src/contrib/cluster/Akka.Cluster.Sharding/ShardCoordinator.cs index dc8f043d64e..4155c9f98d4 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding/ShardCoordinator.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding/ShardCoordinator.cs @@ -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; } diff --git a/src/contrib/cluster/Akka.Cluster.Tools/PublishSubscribe/DistributedPubSubMediator.cs b/src/contrib/cluster/Akka.Cluster.Tools/PublishSubscribe/DistributedPubSubMediator.cs index 4802e4c37d9..de00d5e9340 100644 --- a/src/contrib/cluster/Akka.Cluster.Tools/PublishSubscribe/DistributedPubSubMediator.cs +++ b/src/contrib/cluster/Akka.Cluster.Tools/PublishSubscribe/DistributedPubSubMediator.cs @@ -126,7 +126,7 @@ public static Props Props(DistributedPubSubSettings settings) /// /// TBD /// - public ILoggingAdapter Log { get { return _log ?? (_log = Context.GetLogger()); } } + public ILoggingAdapter Log { get { return _log ??= Context.GetLogger(); } } /// /// TBD diff --git a/src/contrib/cluster/Akka.Cluster.Tools/PublishSubscribe/Internal/TopicMessages.cs b/src/contrib/cluster/Akka.Cluster.Tools/PublishSubscribe/Internal/TopicMessages.cs index 819c9cdd961..a2a80319f0b 100644 --- a/src/contrib/cluster/Akka.Cluster.Tools/PublishSubscribe/Internal/TopicMessages.cs +++ b/src/contrib/cluster/Akka.Cluster.Tools/PublishSubscribe/Internal/TopicMessages.cs @@ -159,7 +159,7 @@ public ValueHolder(long version, IActorRef @ref) /// /// TBD /// - 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; } } /// public bool Equals(ValueHolder other) diff --git a/src/contrib/cluster/Akka.Cluster.Tools/Singleton/ClusterSingletonManager.cs b/src/contrib/cluster/Akka.Cluster.Tools/Singleton/ClusterSingletonManager.cs index 848a1caffd9..721752e04a3 100644 --- a/src/contrib/cluster/Akka.Cluster.Tools/Singleton/ClusterSingletonManager.cs +++ b/src/contrib/cluster/Akka.Cluster.Tools/Singleton/ClusterSingletonManager.cs @@ -707,7 +707,7 @@ private void SetupCoordinatedShutdown() }); } - private ILoggingAdapter Log { get { return _log ?? (_log = Context.GetLogger()); } } + private ILoggingAdapter Log { get { return _log ??= Context.GetLogger(); } } /// protected override void PreStart() diff --git a/src/contrib/cluster/Akka.Cluster.Tools/Singleton/ClusterSingletonProxy.cs b/src/contrib/cluster/Akka.Cluster.Tools/Singleton/ClusterSingletonProxy.cs index 178123b3b3c..b624426555b 100644 --- a/src/contrib/cluster/Akka.Cluster.Tools/Singleton/ClusterSingletonProxy.cs +++ b/src/contrib/cluster/Akka.Cluster.Tools/Singleton/ClusterSingletonProxy.cs @@ -162,7 +162,7 @@ public ClusterSingletonProxy(string singletonManagerPath, ClusterSingletonProxyS }); } - private ILoggingAdapter Log => _log ?? (_log = Context.GetLogger()); + private ILoggingAdapter Log => _log ??= Context.GetLogger(); /// /// TBD diff --git a/src/contrib/cluster/Akka.DistributedData/ReadWriteAggregator.cs b/src/contrib/cluster/Akka.DistributedData/ReadWriteAggregator.cs index 9d0ade1a0c3..9c7d37f35c8 100644 --- a/src/contrib/cluster/Akka.DistributedData/ReadWriteAggregator.cs +++ b/src/contrib/cluster/Akka.DistributedData/ReadWriteAggregator.cs @@ -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; } diff --git a/src/contrib/persistence/Akka.Persistence.Query.InMemory/AllEventsPublisher.cs b/src/contrib/persistence/Akka.Persistence.Query.InMemory/AllEventsPublisher.cs index 3ceeb5a36da..8063f57db06 100644 --- a/src/contrib/persistence/Akka.Persistence.Query.InMemory/AllEventsPublisher.cs +++ b/src/contrib/persistence/Akka.Persistence.Query.InMemory/AllEventsPublisher.cs @@ -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 Buffer { get; } protected int FromOffset { get; } diff --git a/src/contrib/persistence/Akka.Persistence.Query.InMemory/EventsByPersistenceIdPublisher.cs b/src/contrib/persistence/Akka.Persistence.Query.InMemory/EventsByPersistenceIdPublisher.cs index 0b2c85108ff..b3be195a336 100644 --- a/src/contrib/persistence/Akka.Persistence.Query.InMemory/EventsByPersistenceIdPublisher.cs +++ b/src/contrib/persistence/Akka.Persistence.Query.InMemory/EventsByPersistenceIdPublisher.cs @@ -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; } diff --git a/src/contrib/persistence/Akka.Persistence.Query.InMemory/EventsByTagPublisher.cs b/src/contrib/persistence/Akka.Persistence.Query.InMemory/EventsByTagPublisher.cs index 9d863a7f344..b698ef22d19 100644 --- a/src/contrib/persistence/Akka.Persistence.Query.InMemory/EventsByTagPublisher.cs +++ b/src/contrib/persistence/Akka.Persistence.Query.InMemory/EventsByTagPublisher.cs @@ -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; } diff --git a/src/core/Akka.Cluster/SBR/SplitBrainResolver.cs b/src/core/Akka.Cluster/SBR/SplitBrainResolver.cs index bd4e4575e2c..ac6ae0224f8 100644 --- a/src/core/Akka.Cluster/SBR/SplitBrainResolver.cs +++ b/src/core/Akka.Cluster/SBR/SplitBrainResolver.cs @@ -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; } diff --git a/src/core/Akka.Cluster/SplitBrainResolver.cs b/src/core/Akka.Cluster/SplitBrainResolver.cs index 01858154189..b2f0450d550 100644 --- a/src/core/Akka.Cluster/SplitBrainResolver.cs +++ b/src/core/Akka.Cluster/SplitBrainResolver.cs @@ -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() { diff --git a/src/core/Akka.Coordination/LeaseProvider.cs b/src/core/Akka.Coordination/LeaseProvider.cs index bb3452010d3..1fb89ab6604 100644 --- a/src/core/Akka.Coordination/LeaseProvider.cs +++ b/src/core/Akka.Coordination/LeaseProvider.cs @@ -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"); } } /// /// Initializes a new instance of the class. diff --git a/src/core/Akka.Persistence.Query/PersistenceQuery.cs b/src/core/Akka.Persistence.Query/PersistenceQuery.cs index c959f4ad33c..d8fe409a692 100644 --- a/src/core/Akka.Persistence.Query/PersistenceQuery.cs +++ b/src/core/Akka.Persistence.Query/PersistenceQuery.cs @@ -25,7 +25,7 @@ public static PersistenceQuery Get(ActorSystem system) return system.WithExtension(); } - public ILoggingAdapter Log => _log ?? (_log = _system.Log); + public ILoggingAdapter Log => _log ??= _system.Log; public PersistenceQuery(ExtendedActorSystem system) { diff --git a/src/core/Akka.Persistence.Tests/AtLeastOnceDeliveryCrashSpec.cs b/src/core/Akka.Persistence.Tests/AtLeastOnceDeliveryCrashSpec.cs index b5bd9bea650..f0a77de7ed7 100644 --- a/src/core/Akka.Persistence.Tests/AtLeastOnceDeliveryCrashSpec.cs +++ b/src/core/Akka.Persistence.Tests/AtLeastOnceDeliveryCrashSpec.cs @@ -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) { diff --git a/src/core/Akka.Persistence.Tests/AtLeastOnceDeliveryFailureSpec.cs b/src/core/Akka.Persistence.Tests/AtLeastOnceDeliveryFailureSpec.cs index 9a0d43b59bb..750b87968d1 100644 --- a/src/core/Akka.Persistence.Tests/AtLeastOnceDeliveryFailureSpec.cs +++ b/src/core/Akka.Persistence.Tests/AtLeastOnceDeliveryFailureSpec.cs @@ -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))) @@ -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) { diff --git a/src/core/Akka.Persistence/Fsm/PersistentFSMBase.cs b/src/core/Akka.Persistence/Fsm/PersistentFSMBase.cs index 6fba220839d..76d8b4fb9c7 100644 --- a/src/core/Akka.Persistence/Fsm/PersistentFSMBase.cs +++ b/src/core/Akka.Persistence/Fsm/PersistentFSMBase.cs @@ -398,7 +398,7 @@ private StateFunction HandleEventDefault private StateFunction HandleEvent { - get { return _handleEvent ?? (_handleEvent = HandleEventDefault); } + get { return _handleEvent ??= HandleEventDefault; } set { _handleEvent = value; } } diff --git a/src/core/Akka.Remote/Transport/AkkaProtocolTransport.cs b/src/core/Akka.Remote/Transport/AkkaProtocolTransport.cs index 4b8f7e1eb3f..611934892c0 100644 --- a/src/core/Akka.Remote/Transport/AkkaProtocolTransport.cs +++ b/src/core/Akka.Remote/Transport/AkkaProtocolTransport.cs @@ -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); } } diff --git a/src/core/Akka.Streams/Implementation/ActorProcessor.cs b/src/core/Akka.Streams/Implementation/ActorProcessor.cs index 4d09d0c0859..17c73596b6d 100644 --- a/src/core/Akka.Streams/Implementation/ActorProcessor.cs +++ b/src/core/Akka.Streams/Implementation/ActorProcessor.cs @@ -619,7 +619,7 @@ protected ActorProcessorImpl(ActorMaterializerSettings settings) /// /// TBD /// - protected ILoggingAdapter Log => _log ?? (_log = Context.GetLogger()); + protected ILoggingAdapter Log => _log ??= Context.GetLogger(); /// /// TBD diff --git a/src/core/Akka.Streams/Implementation/ActorRefSourceActor.cs b/src/core/Akka.Streams/Implementation/ActorRefSourceActor.cs index cc33097ea59..f957d72b394 100644 --- a/src/core/Akka.Streams/Implementation/ActorRefSourceActor.cs +++ b/src/core/Akka.Streams/Implementation/ActorRefSourceActor.cs @@ -68,7 +68,7 @@ public ActorRefSourceActor(int bufferSize, OverflowStrategy overflowStrategy, in /// /// TBD /// - protected ILoggingAdapter Log => _log ?? (_log = Context.GetLogger()); + protected ILoggingAdapter Log => _log ??= Context.GetLogger(); /// /// TBD diff --git a/src/core/Akka.Streams/Implementation/FanIn.cs b/src/core/Akka.Streams/Implementation/FanIn.cs index 09e39799f87..773bbe39b48 100644 --- a/src/core/Akka.Streams/Implementation/FanIn.cs +++ b/src/core/Akka.Streams/Implementation/FanIn.cs @@ -666,7 +666,7 @@ protected FanIn(ActorMaterializerSettings settings, int inputCount) /// /// TBD /// - protected ILoggingAdapter Log => _log ?? (_log = Context.GetLogger()); + protected ILoggingAdapter Log => _log ??= Context.GetLogger(); private ILoggingAdapter _log; /// diff --git a/src/core/Akka.Streams/Implementation/FanOut.cs b/src/core/Akka.Streams/Implementation/FanOut.cs index fcf84af4303..9d43d76861b 100644 --- a/src/core/Akka.Streams/Implementation/FanOut.cs +++ b/src/core/Akka.Streams/Implementation/FanOut.cs @@ -590,7 +590,7 @@ protected FanOut(ActorMaterializerSettings settings, int outputCount) /// /// TBD /// - protected ILoggingAdapter Log => _log ?? (_log = Context.GetLogger()); + protected ILoggingAdapter Log => _log ??= Context.GetLogger(); private ILoggingAdapter _log; /// diff --git a/src/core/Akka.Streams/Implementation/Fusing/ActorGraphInterpreter.cs b/src/core/Akka.Streams/Implementation/Fusing/ActorGraphInterpreter.cs index 9fb6ab710a8..63dddddf24e 100644 --- a/src/core/Akka.Streams/Implementation/Fusing/ActorGraphInterpreter.cs +++ b/src/core/Akka.Streams/Implementation/Fusing/ActorGraphInterpreter.cs @@ -185,11 +185,11 @@ public GraphInterpreterShell(GraphAssembly assembly, Connection[] connections, G /// /// TBD /// - public ILoggingAdapter Log => _log ?? (_log = GetLogger()); + public ILoggingAdapter Log => _log ??= GetLogger(); /// /// TBD /// - public GraphInterpreter Interpreter => _interpreter ?? (_interpreter = GetInterpreter()); + public GraphInterpreter Interpreter => _interpreter ??= GetInterpreter(); /// /// TBD @@ -1358,7 +1358,7 @@ public ActorGraphInterpreter(GraphInterpreterShell shell) /// /// TBD /// - public ILoggingAdapter Log => _log ?? (_log = Context.GetLogger()); + public ILoggingAdapter Log => _log ??= Context.GetLogger(); private void EnqueueToShortCircuit(object input) { diff --git a/src/core/Akka.Streams/Implementation/Fusing/GraphInterpreter.cs b/src/core/Akka.Streams/Implementation/Fusing/GraphInterpreter.cs index 527ca99a4bc..92598a55dc4 100644 --- a/src/core/Akka.Streams/Implementation/Fusing/GraphInterpreter.cs +++ b/src/core/Akka.Streams/Implementation/Fusing/GraphInterpreter.cs @@ -505,7 +505,7 @@ private string QueueStatus() /// /// TBD /// - internal string Name => _name ?? (_name = GetHashCode().ToString("x")); + internal string Name => _name ??= GetHashCode().ToString("x"); /// /// Assign the boundary logic to a given connection. This will serve as the interface to the external world diff --git a/src/core/Akka.Streams/Implementation/StreamRef/SinkRefImpl.cs b/src/core/Akka.Streams/Implementation/StreamRef/SinkRefImpl.cs index b5946b31f1b..20807abed2b 100644 --- a/src/core/Akka.Streams/Implementation/StreamRef/SinkRefImpl.cs +++ b/src/core/Akka.Streams/Implementation/StreamRef/SinkRefImpl.cs @@ -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; diff --git a/src/core/Akka.Streams/Implementation/StreamRef/SourceRefImpl.cs b/src/core/Akka.Streams/Implementation/StreamRef/SourceRefImpl.cs index 5dc63f8f267..f64bbac3056 100644 --- a/src/core/Akka.Streams/Implementation/StreamRef/SourceRefImpl.cs +++ b/src/core/Akka.Streams/Implementation/StreamRef/SourceRefImpl.cs @@ -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 diff --git a/src/core/Akka/Actor/ActorBase.SupervisorStrategy.cs b/src/core/Akka/Actor/ActorBase.SupervisorStrategy.cs index 83ca92896a8..d29c30e07db 100644 --- a/src/core/Akka/Actor/ActorBase.SupervisorStrategy.cs +++ b/src/core/Akka/Actor/ActorBase.SupervisorStrategy.cs @@ -18,7 +18,7 @@ public abstract partial class ActorBase /// internal SupervisorStrategy SupervisorStrategyInternal { - get { return _supervisorStrategy ?? (_supervisorStrategy = SupervisorStrategy()); } + get { return _supervisorStrategy ??= SupervisorStrategy(); } set { _supervisorStrategy = value; } } diff --git a/src/core/Akka/Actor/FSM.cs b/src/core/Akka/Actor/FSM.cs index be4fd5ed0cb..058af405d24 100644 --- a/src/core/Akka/Actor/FSM.cs +++ b/src/core/Akka/Actor/FSM.cs @@ -1064,7 +1064,7 @@ private StateFunction HandleEventDefault private StateFunction HandleEvent { - get { return _handleEvent ?? (_handleEvent = HandleEventDefault); } + get { return _handleEvent ??= HandleEventDefault; } set { _handleEvent = value; } } diff --git a/src/core/Akka/Configuration/Hocon/AkkaConfigurationSection.cs b/src/core/Akka/Configuration/Hocon/AkkaConfigurationSection.cs index e605492d551..6bf9cf19581 100644 --- a/src/core/Akka/Configuration/Hocon/AkkaConfigurationSection.cs +++ b/src/core/Akka/Configuration/Hocon/AkkaConfigurationSection.cs @@ -36,7 +36,7 @@ public class AkkaConfigurationSection : ConfigurationSection /// public Config AkkaConfig { - get { return _akkaConfig ?? (_akkaConfig = ConfigurationFactory.ParseString(Hocon.Content)); } + get { return _akkaConfig ??= ConfigurationFactory.ParseString(Hocon.Content); } } /// diff --git a/src/core/Akka/Routing/ConsistentHash.cs b/src/core/Akka/Routing/ConsistentHash.cs index e0f094b6686..5d12626616a 100644 --- a/src/core/Akka/Routing/ConsistentHash.cs +++ b/src/core/Akka/Routing/ConsistentHash.cs @@ -50,7 +50,7 @@ public ConsistentHash(SortedDictionary 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