Проблема: если возвращать из обработчика Task без использования ключевых слов async/await, приложение падает с таким исключением:
System.NullReferenceException: Object reference not set to an instance of an object.
at Npgsql.ConnectorPool.Release(NpgsqlConnector connector) in C:\projects\npgsql\src\Npgsql\ConnectorPool.cs:line 446
at Npgsql.NpgsqlConnection.Close(Boolean wasBroken) in C:\projects\npgsql\src\Npgsql\NpgsqlConnection.cs:line 630
at Npgsql.NpgsqlConnection.Close() in C:\projects\npgsql\src\Npgsql\NpgsqlConnection.cs:line 615
at Npgsql.NpgsqlConnection.Dispose(Boolean disposing) in C:\projects\npgsql\src\Npgsql\NpgsqlConnection.cs:line 670
at System.ComponentModel.Component.Dispose()
at SomeApp.Application.UseCases.ListLanguagesHandler.HandleAsync(ListLanguages userCase, CancellationToken cancellationToken) in /Volumes/Data/Workspace/Coding/SomeApp/Backend/SomeApp.Application/UseCases/ListLanguages.cs:line 45
at SomeApp.Application.UseCaseDispatcher.HandleAsync[TUseCase,TResult](TUseCase useCase, CancellationToken cancellationToken) in /Volumes/Data/Workspace/Coding/SomeApp/Backend/SomeApp.Application/UseCaseDispatcher.cs:line 42
at SomeApp.Startup.<>c.<<ConfigureV1Routes>b__4_4>d.MoveNext() in /Volumes/Data/Workspace/Coding/SomeApp/Backend/SomeApp/Startup.cs:line 67
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request finished in 37953.763ms 0```
Вопрос: почему так происходит?