You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Due to the bug on Android 6.0 and below, when you override fillInStackTrace and don't call super method, under-the-hood the exception stack trace not filled by nativeFillInStackTrace() method, so next time when you try to call getStackTrace(), under-the-hood the nativeGetStackTrace() method will return null and clone() will be called on that null.
Solution
To fix this issue you should set empty stack trace, when overriding fillInStackTrace method, like following:
Here is simple example:
When you run the code above on Android 6.0 and lower, application will crash with following exception:
The analogue issue is akaita/RxJava2Debug#2
Due to the bug on Android 6.0 and below, when you override
fillInStackTrace
and don't call super method, under-the-hood the exception stack trace not filled by nativeFillInStackTrace() method, so next time when you try to call getStackTrace(), under-the-hood the nativeGetStackTrace() method will returnnull
and clone() will be called on thatnull
.Solution
To fix this issue you should set empty stack trace, when overriding
fillInStackTrace
method, like following:Also to reduce garbage, this empty array can be defined as global constant.
This fix must be applied to all custom exceptions, those override
fillInStackTrace
, currently these are:kotlinx.coroutines/kotlinx-coroutines-core/jvm/src/Exceptions.kt
Line 29 in d7de5f5
kotlinx.coroutines/kotlinx-coroutines-core/jvm/src/flow/internal/FlowExceptions.kt
Line 10 in d7de5f5
kotlinx.coroutines/kotlinx-coroutines-core/jvm/src/flow/internal/FlowExceptions.kt
Line 20 in d7de5f5
Workaround
Enable Debug Mode, so that
fillInStackTrace
will work as expected.The text was updated successfully, but these errors were encountered: