Fixed size error when cleaning the stack trace

This commit is contained in:
nathan 2020-08-17 16:47:50 +02:00
parent 305e3bb085
commit cd42f6b85d

View File

@ -32,7 +32,9 @@ internal class ListenerManager<CONNECTION: Connection>(private val logger: KLogg
fun cleanStackTrace(throwable: Throwable) {
// NOTE: when we remove stuff, we ONLY want to remove the "tail" of the stacktrace, not ALL parts of the stacktrace
val stackTrace = throwable.stackTrace
var newEndIndex = stackTrace.size - 1
var newEndIndex = Math.max(0, stackTrace.size - 1)
if (newEndIndex > 0) {
for (i in newEndIndex downTo 0) {
val stackName = stackTrace[i].className
if (i == newEndIndex) {
@ -51,6 +53,7 @@ internal class ListenerManager<CONNECTION: Connection>(private val logger: KLogg
throwable.stackTrace = stackTrace.copyOfRange(0, newEndIndex)
}
}
}
// initialize a emtpy arrays
private val onConnectIpFilterList = atomic(Array<IpFilterRule>(0) { IpSubnetFilterRule.fake })
@ -237,10 +240,10 @@ internal class ListenerManager<CONNECTION: Connection>(private val logger: KLogg
// first run through the IP connection filters, THEN run through the "custom" filters
val address = connection.remoteAddressInt
// val address = connection.remoteAddressInt
// it's possible for a remote address to match MORE than 1 rule.
var isAllowed = false
// var isAllowed = false
// these are the IP filters (optimized checking based on simple IP rules)
onConnectIpFilterList.value.forEach {