fusesource / jansi

Jansi is a small java library that allows you to use ANSI escape sequences to format your console output which works even on windows.
http://fusesource.github.io/jansi/
Apache License 2.0
1.12k stars 139 forks source link

Improve robustness of initial cleanup #255

Closed gnodet closed 1 year ago

gnodet commented 1 year ago
          I second this issue.  I've been seeing IntelliJ hang recently, when I start a maven command.  I attached a debugger to maven, and it's stuck here:
"main" #1 prio=5 os_prio=0 cpu=250.00ms elapsed=167.88s tid=0x0000023b2d9c8710 nid=0x3bc4 runnable  [0x000000505eafd000]
   java.lang.Thread.State: RUNNABLE
        at java.io.WinNTFileSystem.delete0(java.base@17.0.2/Native Method)
        at java.io.WinNTFileSystem.delete(java.base@17.0.2/WinNTFileSystem.java:580)
        at java.io.File.delete(java.base@17.0.2/File.java:1073)
        at org.fusesource.jansi.internal.JansiLoader.cleanup(JansiLoader.java:103)
        at org.fusesource.jansi.internal.JansiLoader.initialize(JansiLoader.java:59)
        - locked <0x0000000623416228> (a java.lang.Class for org.fusesource.jansi.internal.JansiLoader)
        at org.fusesource.jansi.internal.CLibrary.<clinit>(CLibrary.java:36)
        at org.fusesource.jansi.AnsiConsole.ansiStream(AnsiConsole.java:255)
        at org.fusesource.jansi.AnsiConsole.initStreams(AnsiConsole.java:559)
        - locked <0x0000000623be3f58> (a java.lang.Class for org.fusesource.jansi.AnsiConsole)
        at org.fusesource.jansi.AnsiConsole.systemInstall(AnsiConsole.java:513)
        - locked <0x0000000623be3f58> (a java.lang.Class for org.fusesource.jansi.AnsiConsole)
        at org.apache.maven.shared.utils.logging.MessageUtils.systemInstall(MessageUtils.java:67)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:194)
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(java.base@17.0.2/Native Method)
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base@17.0.2/NativeMethodAccessorImpl.java:77)
        at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base@17.0.2/DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(java.base@17.0.2/Method.java:568)
...

So AnsiConsole.systemInstall wants to delete a file. Not what I would have expected. I checked and "System" has the file open. Even after closing all applications, the file is still locked, and I cannot delete it.

Originally posted by @mrsalt in https://github.com/fusesource/jansi/issues/244#issuecomment-1585208527