Files
assistant-android/app/src/main/java/com/gh/common/exposure/ExposureTraceUtils.kt

27 lines
759 B
Kotlin
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.gh.common.exposure
object ExposureTraceUtils {
fun appendTrace(event: ExposureEvent?): List<ExposureEvent> {
val traceList = arrayListOf<ExposureEvent>()
event?.let {
//这里使用deepCopy是为了防止循环引用调用hashCode方法触发StackOverflowError错误
val deepCopy = it.deepCopy()
if (deepCopy.eTrace == null) {
traceList.add(deepCopy)
} else {
traceList.addAll(deepCopy.eTrace!!)
traceList.add(flattenTrace(deepCopy))
}
}
return traceList
}
private fun flattenTrace(event: ExposureEvent): ExposureEvent {
event.eTrace = arrayListOf()
return event
}
}