SumoLogic / sumologic-net-appenders

Several appenders for .NET developers to use that send logs straight to SumoLogic.
Apache License 2.0
23 stars 39 forks source link

handle exceptions when buffered sender disposed w/ outstanding timer callbacks #78

Closed ezrapagel closed 5 years ago

ezrapagel commented 5 years ago

We have some code that creates a log4net instance before calling Configure(), so we dispose/replace the BufferedSender, potentially w/ outstanding timer callbacks performing flushes. This can cause ObjectDisposedExceptions due to the HttpClient instance already having been disposed. Even though this is probably incorrect log4net usage, the appender should be handle this gracefully.

We've also seen unhandled TaskCancelledExceptions with similar callstacks. This is a regression in 1.0.0.11; previously this case was handled due to AggregateException being caught, but now the exception is unrolled when we await.

A more correct way to mitigate this case would be to block on Dispose using the Timer's WaitHandle overload until any outstanding callbacks complete, but dotnet standard 1.3 doesn't have this overload for some reason (2+ restore it). So this PR just warns and suppresses the error.