Skip to content

Commit e471682

Browse files
committed
feat(payload): add a substitute thread to the payload when excess threads have been trimmed in EventPayload
1 parent e29746e commit e471682

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

bugsnag-android-core/src/main/java/com/bugsnag/android/EventPayload.kt

+23
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,29 @@ class EventPayload @JvmOverloads internal constructor(
8080
dataTrimmed
8181
)
8282

83+
val threadCount = event.threads.size
84+
val maxReportedThreads = config.maxReportedThreads
85+
if (threadCount > maxReportedThreads) {
86+
event.threads.subList(maxReportedThreads, threadCount).clear()
87+
88+
event.threads.add(
89+
Thread(
90+
"",
91+
"[${threadCount - maxReportedThreads} threads omitted as the " +
92+
"maxReportedThreads limit ($maxReportedThreads) was exceeded]",
93+
ErrorType.UNKNOWN,
94+
false,
95+
Thread.State.UNKNOWN,
96+
Stacktrace(
97+
arrayOf(StackTraceElement("", "", "-", 0)),
98+
config.projectPackages,
99+
logger
100+
),
101+
logger
102+
)
103+
)
104+
}
105+
83106
json = rebuildPayloadCache()
84107
if (json.size <= maxSizeBytes) {
85108
return this

0 commit comments

Comments
 (0)