cleanStackTraceInternal now cleans the stack track from all coroutine info for all dorkbox.network stack traces.
This commit is contained in:
parent
533aec6c2d
commit
113de5d12e
|
@ -96,7 +96,7 @@ internal class ListenerManager<CONNECTION: Connection>(private val logger: KLogg
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove from the stacktrace (going in reverse), kotlin coroutine info ONLY. This is for internal logs when a problem happens INSIDE the network stack
|
* Remove from the stacktrace kotlin coroutine info ONLY that is inside the network stack. This is for internal logs when a problem happens INSIDE the network stack.
|
||||||
*
|
*
|
||||||
* Neither of these are useful in resolving exception handling from a users perspective, and only clutter the stacktrace.
|
* Neither of these are useful in resolving exception handling from a users perspective, and only clutter the stacktrace.
|
||||||
*/
|
*/
|
||||||
|
@ -109,29 +109,18 @@ internal class ListenerManager<CONNECTION: Connection>(private val logger: KLogg
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var newEndIndex = size - 1 // offset by 1 because we have to adjust for the access index
|
// we want to ONLY filter stuff that is past the highest dorkbox index AND is a coroutine.
|
||||||
|
val firstDorkboxIndex = stackTrace.indexOfFirst { it.className.startsWith("dorkbox.network.") }
|
||||||
for (i in newEndIndex downTo 0) {
|
val lastDorkboxIndex = stackTrace.indexOfLast { it.className.startsWith("dorkbox.network.") }
|
||||||
val stackName = stackTrace[i].className
|
throwable.stackTrace = stackTrace.filterIndexed { index, element ->
|
||||||
if (i == newEndIndex) {
|
val stackName = element.className
|
||||||
if (stackName.startsWith("kotlinx.coroutines.") ||
|
if (index <= firstDorkboxIndex && index >= lastDorkboxIndex) {
|
||||||
stackName.startsWith("kotlin.coroutines.")) {
|
true
|
||||||
newEndIndex--
|
|
||||||
} else {
|
} else {
|
||||||
break
|
!(stackName.startsWith("kotlinx.coroutines.") ||
|
||||||
}
|
stackName.startsWith("kotlin.coroutines."))
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
newEndIndex++ // have to add 1 back, because a copy must be by size (and we access from 0)
|
|
||||||
|
|
||||||
if (newEndIndex > 0) {
|
|
||||||
// newEndIndex will also remove the VERY LAST CachedMethod or CachedAsmMethod access invocation (because it's offset by 1)
|
|
||||||
throwable.stackTrace = stackTrace.copyOfRange(0, newEndIndex)
|
|
||||||
} else {
|
|
||||||
// keep just one, since it's a stack frame INSIDE our network library, and we need that!
|
|
||||||
throwable.stackTrace = stackTrace.copyOfRange(0, 1)
|
|
||||||
}
|
}
|
||||||
|
}.toTypedArray()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -186,10 +186,13 @@ internal class ClientHandshake<CONNECTION: Connection>(
|
||||||
ListenerManager.cleanStackTraceInternal(failedEx)
|
ListenerManager.cleanStackTraceInternal(failedEx)
|
||||||
throw failedEx
|
throw failedEx
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connectionHelloInfo == null) {
|
if (connectionHelloInfo == null) {
|
||||||
// no longer necessary to hold this connection open (if not a failure, we close the handshake after the DONE message)
|
// no longer necessary to hold this connection open (if not a failure, we close the handshake after the DONE message)
|
||||||
handshakeConnection.close()
|
handshakeConnection.close()
|
||||||
throw ClientTimedOutException("Waiting for registration response from server")
|
val exception = ClientTimedOutException("Waiting for registration response from server")
|
||||||
|
ListenerManager.cleanStackTraceInternal(exception)
|
||||||
|
throw exception
|
||||||
}
|
}
|
||||||
|
|
||||||
return connectionHelloInfo!!
|
return connectionHelloInfo!!
|
||||||
|
@ -203,7 +206,6 @@ internal class ClientHandshake<CONNECTION: Connection>(
|
||||||
try {
|
try {
|
||||||
endPoint.writeHandshakeMessage(handshakeConnection.publication, registrationMessage)
|
endPoint.writeHandshakeMessage(handshakeConnection.publication, registrationMessage)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
logger.error("Handshake error!", e)
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,7 +249,9 @@ internal class ClientHandshake<CONNECTION: Connection>(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!connectionDone) {
|
if (!connectionDone) {
|
||||||
throw ClientTimedOutException("Waiting for registration response from server")
|
val exception = ClientTimedOutException("Waiting for registration response from server")
|
||||||
|
ListenerManager.cleanStackTraceInternal(exception)
|
||||||
|
throw exception
|
||||||
}
|
}
|
||||||
|
|
||||||
return connectionDone
|
return connectionDone
|
||||||
|
|
Loading…
Reference in New Issue
Block a user