Skip to content

Commit 3727aed

Browse files
authored
Fix a NPE in startup profiler (#2124)
* Add null check * Fix spotless
1 parent 36d77da commit 3727aed

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

agent/agent/src/main/java/com/microsoft/applicationinsights/agent/StartupProfiler.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ private void captureThreadDump() {
103103
threadBean.getAllThreadIds(), threadBean.isObjectMonitorUsageSupported(), false);
104104
long currentThreadId = Thread.currentThread().getId();
105105
for (ThreadInfo threadInfo : threadInfos) {
106+
// If a thread of a given ID is not alive or does not exist, the corresponding element in
107+
// the returned array will contain null
108+
if (threadInfo == null) {
109+
continue;
110+
}
111+
106112
if (threadInfo.getThreadId() != currentThreadId) {
107113
write(threadInfo);
108114
}

0 commit comments

Comments
 (0)