【发布时间】:2020-05-11 16:52:10
【问题描述】:
我有一个带有 .net 核心网络应用程序的 docker 容器。
docker 已退出,错误代码为 139。
Docker 检查没有 oom 指示
当我查看日志时,我看到了这一点,没有更多提示:
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
at Services.Web.Services.ProductClient.RunCient.<>c__DisplayClass5_0.<<ScrapeProfileInfo>b__0>d.MoveNext() in /src/Services.Web/Services/Clients/ProductClient.cs:line 30
--- End of stack trace from previous location where exception was thrown ---
at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__139_1(Object state)
at System.Threading.QueueUserWorkItemCallback.<>c.<.cctor>b__6_0(QueueUserWorkItemCallback quwi)
at System.Threading.ExecutionContext.RunForThreadPoolUnsafe[TState](ExecutionContext executionContext, Action`1 callback, TState& state)
at System.Threading.QueueUserWorkItemCallback.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
在ProductClient.cs: line 30 中没有潜在的空异常风险...
if (txt == string.Empty) return;
- 什么可能导致这个异常,这条线完全没有风险?
- Docker 不会因为一个异常而存在,它是否暗示了可能发生的事情?
我托管在 Google 云平台上。 docker 位于计算引擎下的 ubuntu 服务器上...(docker-compose)
更新
构建是 docker buildRUN dotnet build "TestServices.Web.csproj" -c Release -o /app/build
不使用 c# 可为空的特性
谢谢
【问题讨论】:
-
你的代码是在调试还是发布模式下编译的?你在使用可空值吗?你能提供更多代码的概述吗?