Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enableThreadInfo() resets the thread interrupted flag #148

Open
LightWeek opened this issue Aug 21, 2023 · 1 comment
Open

enableThreadInfo() resets the thread interrupted flag #148

LightWeek opened this issue Aug 21, 2023 · 1 comment

Comments

@LightWeek
Copy link

LightWeek commented Aug 21, 2023

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.

@LightWeek
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant