Skip to content
Open
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 @@ -232,9 +232,15 @@ public void Messages_can_be_muted_from_now_on_with_using()
[Fact]
public async Task Make_sure_async_works()
{
await _testingEventFilter.ForLogLevel(LogLevel).ExpectAsync(1, TimeSpan.FromSeconds(2), () => {
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
Task.Delay(TimeSpan.FromMilliseconds(10)).ContinueWith(_ => { LogMessage("whatever"); });
await _testingEventFilter.ForLogLevel(LogLevel).ExpectAsync(1, TimeSpan.FromSeconds(2), () =>
{
#pragma warning disable CS4014 // intentionally fire-and-forget to verify filter after action returns
_ = Task.Run(async () =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the ConfigureAwait(false) the only meaningful change here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, its the Task.Run()

{
await Task.Delay(TimeSpan.FromMilliseconds(10)).ConfigureAwait(false);
LogMessage("whatever");
});
#pragma warning restore CS4014
return Task.CompletedTask;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,13 +404,15 @@ protected async Task<T> InterceptAsync<T>(


matchedEventHandler ??= new MatchedEventHandler();
system.EventStream.Publish(new Mute(_filters));
try
{
// Attach handlers before muting to avoid missing early matches
foreach(var filter in _filters)
{
filter.EventMatched += matchedEventHandler.HandleEvent;
}
system.EventStream.Publish(new Mute(_filters));
await Task.Yield();
var result = await func();

if(!await AwaitDoneAsync(timeoutValue, expectedOccurrences, matchedEventHandler, cancellationToken))
Expand Down Expand Up @@ -586,4 +588,4 @@ protected virtual void Dispose(bool disposing)
}
}
}
}
}
3 changes: 1 addition & 2 deletions src/core/Akka.TestKit/EventFilter/TestEventListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@ protected override bool Receive(object message)
{
case InitializeLogger initLogger:
{
base.Receive(message);
var bus = initLogger.LoggingBus;
var self = Context.Self;
bus.Subscribe(self, typeof(Mute));
bus.Subscribe(self, typeof(Unmute));
bus.Subscribe(self, typeof(DeadLetter));
bus.Subscribe(self, typeof(UnhandledMessage));
Sender.Tell(new LoggerInitialized());
base.Receive(message);
break;
}
case Mute mute:
Expand Down
Loading