Skip to content

Commit

Permalink
cleaned up build warnings (#6418)
Browse files Browse the repository at this point in the history
* cleaned up build warnings

* fixed async error handling inside `TcpListener`
  • Loading branch information
Aaronontheweb authored Feb 21, 2023
1 parent 90bedf2 commit b570276
Show file tree
Hide file tree
Showing 19 changed files with 66 additions and 130 deletions.
4 changes: 0 additions & 4 deletions src/core/Akka.Tests/Actor/CoordinatedShutdownSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
using FluentAssertions;
using Xunit;
using static Akka.Actor.CoordinatedShutdown;
using Akka.Tests.Util;
using FluentAssertions;
using FluentAssertions.Extensions;
using static FluentAssertions.FluentActions;

namespace Akka.Tests.Actor
{
Expand Down
7 changes: 5 additions & 2 deletions src/core/Akka.Tests/Actor/SupervisorHierarchySpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ private class ResumerAsync : TestReceiveActor
{
public ResumerAsync()
{
#pragma warning disable CS1998
ReceiveAsync<string>(s => s.StartsWith("spawn:"), async s => Sender.Tell(Context.ActorOf<ResumerAsync>(s.Substring(6))));
ReceiveAsync<string>(s => s.Equals("spawn"), async _ => Sender.Tell(Context.ActorOf<ResumerAsync>()));
ReceiveAsync<string>(s => s.Equals("fail"), async _ => { throw new Exception("expected"); });
ReceiveAsync<string>(s => s.Equals("ping"), async _ => Sender.Tell("pong"));
#pragma warning restore CS1998
}

protected override SupervisorStrategy SupervisorStrategy()
Expand Down Expand Up @@ -166,10 +168,11 @@ public async Task A_supervisor_must_send_notifications_to_supervisor_when_perman
//We then send another "killCrasher", which again will send Kill to crasher. It crashes,
//decider says it should be restarted but since we specified maximum 1 restart/5seconds it will be
//permanently stopped. Boss, which watches crasher, receives Terminated, and counts down countDownMax
await EventFilter.Exception<ActorKilledException>().ExpectAsync(2, async () =>
await EventFilter.Exception<ActorKilledException>().ExpectAsync(2, () =>
{
boss.Tell("killCrasher");
boss.Tell("killCrasher");
return Task.CompletedTask;
});
await countDownMessages.WaitAsync().ShouldCompleteWithin(2.Seconds());
await countDownMax.WaitAsync().ShouldCompleteWithin(2.Seconds());
Expand Down Expand Up @@ -248,7 +251,7 @@ await EventFilter.Warning("expected").ExpectOneAsync(async () => //expected exce
{
//Let boss crash, this means any child under boss should be suspended, so we wait for worker to become suspended.
boss.Tell("fail");
await AwaitConditionAsync(async () => ((LocalActorRef)worker).Cell.Mailbox.IsSuspended());
await AwaitConditionAsync(() => Task.FromResult(((LocalActorRef)worker).Cell.Mailbox.IsSuspended()));

//At this time slowresumer is currently handling the failure, in supervisestrategy, waiting for latch to be opened
//We verify that no message is handled by worker, by sending it a ping
Expand Down
6 changes: 6 additions & 0 deletions src/core/Akka.Tests/Dispatch/AsyncAwaitSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,9 @@ public class AsyncFailingActor : ReceiveActor
{
public AsyncFailingActor()
{
#pragma warning disable CS1998
ReceiveAsync<string>(async m =>
#pragma warning restore CS1998
{
ThrowException();
});
Expand Down Expand Up @@ -463,7 +465,9 @@ public AsyncPipeToDelayActor()
{
ReceiveAsync<string>(async msg =>
{
#pragma warning disable CS4014
Delayed(msg).PipeTo(Sender, Self);
#pragma warning restore CS4014

await Task.Delay(3000);
});
Expand All @@ -483,12 +487,14 @@ public AsyncReentrantActor()
ReceiveAsync<string>(async msg =>
{
var sender = Sender;
#pragma warning disable CS4014
Task.Run(() =>
{
//Sleep to make sure the task is not completed when ContinueWith is called
Thread.Sleep(100);
return msg;
}).ContinueWith(_ => sender.Tell(msg)); // ContinueWith will schedule with the implicit ActorTaskScheduler
#pragma warning restore CS4014

Thread.Sleep(3000);
});
Expand Down
10 changes: 5 additions & 5 deletions src/core/Akka.Tests/Dispatch/MailboxesSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public async Task Can_use_unbounded_priority_mailbox()
actor.SendSystemMessage(new Suspend());

// wait until we can confirm that the mailbox is suspended before we begin sending messages
await AwaitConditionAsync(async () => ((ActorRefWithCell)actor).Underlying is ActorCell actorCell && actorCell.Mailbox.IsSuspended());
await AwaitConditionAsync(() => Task.FromResult(((ActorRefWithCell)actor).Underlying is ActorCell actorCell && actorCell.Mailbox.IsSuspended()));

actor.Tell(true);
for (var i = 0; i < 30; i++)
Expand Down Expand Up @@ -242,7 +242,7 @@ public async Task Can_use_unbounded_stable_priority_mailbox()
actor.SendSystemMessage(new Suspend());

// wait until we can confirm that the mailbox is suspended before we begin sending messages
await AwaitConditionAsync(async () => ((ActorRefWithCell)actor).Underlying is ActorCell actorCell && actorCell.Mailbox.IsSuspended());
await AwaitConditionAsync(() => Task.FromResult(((ActorRefWithCell)actor).Underlying is ActorCell actorCell && actorCell.Mailbox.IsSuspended()));

actor.Tell(true);
for (var i = 0; i < 30; i++)
Expand Down Expand Up @@ -279,7 +279,7 @@ public async Task Priority_mailbox_keeps_ordering_with_many_priority_values()
//pause mailbox until all messages have been told
actor.SendSystemMessage(new Suspend());

await AwaitConditionAsync(async ()=> ((ActorRefWithCell)actor).Underlying is ActorCell actorCell && actorCell.Mailbox.IsSuspended());
await AwaitConditionAsync(()=> Task.FromResult(((ActorRefWithCell)actor).Underlying is ActorCell actorCell && actorCell.Mailbox.IsSuspended()));
// creates 50 messages with values spanning from Int32.MinValue to Int32.MaxValue
var values = new int[50];
var increment = (int)(UInt32.MaxValue / values.Length);
Expand Down Expand Up @@ -317,7 +317,7 @@ public async Task Unbounded_Priority_Mailbox_Supports_Unbounded_Stashing()
//pause mailbox until all messages have been told
actor.SendSystemMessage(new Suspend());

await AwaitConditionAsync(async () => ((ActorRefWithCell)actor).Underlying is ActorCell actorCell && actorCell.Mailbox.IsSuspended());
await AwaitConditionAsync(() => Task.FromResult(((ActorRefWithCell)actor).Underlying is ActorCell actorCell && actorCell.Mailbox.IsSuspended()));

var values = new int[10];
var increment = (int)(UInt32.MaxValue / values.Length);
Expand Down Expand Up @@ -360,7 +360,7 @@ public async Task Unbounded_Stable_Priority_Mailbox_Supports_Unbounded_Stashing(
//pause mailbox until all messages have been told
actor.SendSystemMessage(new Suspend());

await AwaitConditionAsync(async () => ((ActorRefWithCell)actor).Underlying is ActorCell actorCell && actorCell.Mailbox.IsSuspended());
await AwaitConditionAsync(() => Task.FromResult(((ActorRefWithCell)actor).Underlying is ActorCell actorCell && actorCell.Mailbox.IsSuspended()));

var values = new int[10];
var increment = (int)(UInt32.MaxValue / values.Length);
Expand Down
4 changes: 0 additions & 4 deletions src/core/Akka.Tests/Event/LoggerSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
//-----------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Akka.Actor;
using Akka.Configuration;
Expand All @@ -17,7 +14,6 @@
using Xunit;
using Xunit.Abstractions;
using FluentAssertions;
using Akka.Configuration;
using ConfigurationFactory = Akka.Configuration.ConfigurationFactory;

namespace Akka.Tests.Event
Expand Down
1 change: 1 addition & 0 deletions src/core/Akka/Actor/ActorPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ public static bool TryParseParts(ReadOnlySpan<char> path, out ReadOnlySpan<char>
/// Joins this instance.
/// </summary>
/// <param name="prefix">the address or empty</param>
/// <param name="uid">Optional - the UID for this path.</param>
/// <returns> System.String. </returns>
private string Join(ReadOnlySpan<char> prefix, long? uid = null)
{
Expand Down
3 changes: 1 addition & 2 deletions src/core/Akka/Actor/Futures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ internal static IActorRefProvider ResolveProvider(ICanTell self)
if (ActorCell.Current is { } cell) return cell.SystemImpl.Provider;

return null;
break;
}
}
}
Expand All @@ -204,7 +203,7 @@ internal static IActorRefProvider ResolveProvider(ICanTell self)
internal sealed class PromiseActorRef : MinimalActorRef
{
/// <summary>
/// Can't access constructor directly - use <see cref="Apply"/> instead.
/// Can't access constructor directly - use PromiseActorRef.Apply instead.
/// </summary>
private PromiseActorRef(IActorRefProvider provider, TaskCompletionSource<object> promise, string mcn)
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka/Actor/IAutoReceivedMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public override string ToString()
/// <see cref="AddressTerminatedTopic"/> when a remote node is detected to be unreachable and / or decided
/// to be removed.
///
/// The watcher <see cref="DeathWatch"/> subscribes to the <see cref="AddressTerminatedTopic"/> and translates this
/// The watcher subscribes to the <see cref="AddressTerminatedTopic"/> and translates this
/// event to <see cref="Terminated"/>, which is sent to itself.
/// </summary>
internal class AddressTerminated : IAutoReceivedMessage, IPossiblyHarmful, IDeadLetterSuppression
Expand Down
1 change: 1 addition & 0 deletions src/core/Akka/Actor/Internal/ActorSystemImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public ActorSystemImpl(string name)
/// <param name="name">The name given to the actor system.</param>
/// <param name="config">The configuration used to configure the actor system.</param>
/// <param name="setup">The <see cref="ActorSystemSetup"/> used to help programmatically bootstrap the actor system.</param>
/// <param name="guardianProps">Optional - the props from the /user guardian actor.</param>
/// <exception cref="ArgumentException">
/// This exception is thrown if the given <paramref name="name"/> is an invalid name for an actor system.
/// Note that the name must contain only word characters (i.e. [a-zA-Z0-9] plus non-leading '-').
Expand Down
1 change: 0 additions & 1 deletion src/core/Akka/Actor/Props.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ public Props(Deploy deploy, Type type, params object[] args)
/// </remarks>
/// <param name="producer">The type of <see cref="IIndirectActorProducer"/> that will be used to instantiate <see cref="Type"/></param>
/// <param name="deploy">The configuration used to deploy the actor.</param>
/// <param name="strategy">The supervisor strategy to use.</param>
/// <param name="args">The arguments needed to create the actor.</param>
internal Props(IIndirectActorProducer producer, Deploy deploy, params object[] args)
{
Expand Down
1 change: 0 additions & 1 deletion src/core/Akka/Configuration/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@ public virtual IList<byte> GetByteList(string path)
/// Retrieves a list of string values from the specified path in the configuration.
/// </summary>
/// <param name="path">The path that contains the values to retrieve.</param>
/// <param name="strings"></param>
/// <exception cref="InvalidOperationException">This exception is thrown if the current node is undefined.</exception>
/// <returns>The list of string values defined in the specified path.</returns>
public virtual IList<string> GetStringList(string path)
Expand Down
1 change: 1 addition & 0 deletions src/core/Akka/Dispatch/Dispatchers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ public static Config GetConfig(Config config, string id, int depth = 0)
/// <summary>Initializes a new instance of the <see cref="Dispatchers" /> class.</summary>
/// <param name="system">The system.</param>
/// <param name="prerequisites">The prerequisites required for some <see cref="MessageDispatcherConfigurator"/> instances.</param>
/// <param name="logger">The logger for dispatchers.</param>
public Dispatchers(ActorSystem system, IDispatcherPrerequisites prerequisites, ILoggingAdapter logger)
{
_system = system;
Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka/Dispatch/ThreadPoolBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ internal static ThreadType ConfigureThreadType(string threadType)
}

/// <summary>
/// Default settings for <see cref="SingleThreadDispatcher"/> instances.
/// Default settings for SingleThreadDispatcher instances.
/// </summary>
internal static readonly DedicatedThreadPoolSettings DefaultSingleThreadPoolSettings = new DedicatedThreadPoolSettings(1, "DefaultSingleThreadPool");
}
Expand Down
Loading

0 comments on commit b570276

Please sign in to comment.