enableThreadInfo() resets the thread interrupted flag
If you have a thread and logs anything withing the run method using XLog.d("you message here") and the configs have enableThreadInfo(), the interrupted flag will be reset right after the first logged message. The test code:
class LogTestThread : Thread() {
override fun run() {
XLog.d("before interruption")
interrupt()
var isInterruptedBeforeLog = isInterrupted()
XLog.d("after interruption")
var isInterruptedAfterLog = isInterrupted()
}
}
fun main(){
val thread = LogTestThread()
thread.start()
}
In the code above
isInterruptedBeforeLog should be true
and
isInterruptedAfterLog should be true
but isInterruptedAfterLog will be false
But, if you don't enable LogConfiguration.Builder().enableThreadInfo() the code above works as expected.
Well, actually, sometimes, the issue reproduces even if the enableThreadInfo() is not enabled. The library itself messes up with threads. If I replace the log function call with the default logger, the issue goes away, but if I use XLog it reproduces again and again.