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

Race on Terminal.interceptors #55

Closed
mikehearn opened this issue Mar 13, 2022 · 0 comments · Fixed by #59
Closed

Race on Terminal.interceptors #55

mikehearn opened this issue Mar 13, 2022 · 0 comments · Fixed by #59

Comments

@mikehearn
Copy link
Contributor

mikehearn commented Mar 13, 2022

Terminal.interceptors should only be modified whilst holding Terminal.lock but the lock isn't taken in Terminal.addInterceptor or Terminal.removeInterceptor.

I had a quick go at fixing this but you can't use synchronized() in non-JVM code. Actually I'm not sure how you're meant to do locking like this in MPP code.

Exception in thread "Thread-0" java.util.ConcurrentModificationException
        at java.base/java.util.ArrayList$Itr.checkForComodification(ArrayList.java:1013)
        at java.base/java.util.ArrayList$Itr.next(ArrayList.java:967)
        at com.github.ajalt.mordant.internal.MppImplKt.sendInterceptedPrintRequest(MppImpl.kt:160)
        at com.github.ajalt.mordant.terminal.Terminal.sendPrintRequest(Terminal.kt:269)
        at com.github.ajalt.mordant.terminal.Terminal.rawPrint(Terminal.kt:265)
        at com.github.ajalt.mordant.terminal.Terminal.print(Terminal.kt:194)
        at com.github.ajalt.mordant.terminal.PrintTerminalCursor.show(TerminalCursor.kt:158)
        at com.github.ajalt.mordant.internal.JvmTerminalCursor.show(MppImpl.kt:113)
        at hydraulic.factory.progress.FancyTerminalParallelProgressTracker.close(FancyTerminalParallelProgressTracker.kt:390)
        at hydraulic.factory.progress.FancyTerminalParallelProgressTracker.shutdownHook$lambda-0(FancyTerminalParallelProgressTracker.kt:46)
        at java.base/java.lang.Thread.run(Thread.java:833)
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

Successfully merging a pull request may close this issue.

1 participant