Skip to content
Merged
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 @@ -8,6 +8,7 @@
using System;
using Akka.Actor;
using Akka.Event;
using Akka.Util;
using Xunit.Abstractions;

namespace Akka.TestKit.Xunit2.Internals
Expand Down Expand Up @@ -58,7 +59,8 @@ private void HandleLogEvent(LogEvent e)
}
catch (InvalidOperationException ie)
{
Console.WriteLine($"Received InvalidOperationException: {ie} - probably because the test had completed executing.");
StandardOutWriter.WriteLine($"Received InvalidOperationException: {ie} - probably because the test had completed executing.");
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see where this is defined. _output.WriteLine not safe here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Per #5722 - we have to stop writing to _output because xUnit will throw an InvalidOperationException when there is no active test. The logger is being shutdown after the test has already ended since this is asynchronous, but because there might still be pending log messages this can create the situation we were trying to avoid.

So we write out to the console via the StandardOutWriter instead since we no longer have access to _output and want to avoid a continuous cycle of throw / crash / write to Output / throw

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, make sense!

Context.Stop(Self); // shut ourselves down, can't do our job any longer
}
}
}
Expand Down