Skip to content
New issue

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

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

Already on GitHub? # to your account

Watch service exception on shutdown #188

Closed
niloc132 opened this issue Jul 17, 2022 · 7 comments
Closed

Watch service exception on shutdown #188

niloc132 opened this issue Jul 17, 2022 · 7 comments
Labels
bug Something isn't working
Milestone

Comments

@niloc132
Copy link
Member

When stopping the JVM that is running the plugin, sometimes a stack trace will be printed. On a mac, this might look like this:

Exception in thread "DiskCacheThread" java.nio.file.ClosedWatchServiceException
        at io.methvin.watchservice.AbstractWatchService.check(AbstractWatchService.java:94)
        at io.methvin.watchservice.AbstractWatchService.take(AbstractWatchService.java:86)
        at io.methvin.watchservice.MacOSXListeningWatchService.take(MacOSXListeningWatchService.java:38)
        at com.vertispan.j2cl.build.DiskCache.checkForWork(DiskCache.java:121)
        at java.base/java.lang.Thread.run(Thread.java:829)

This can affect stopping a j2cl:watch or a successful j2cl:build/j2cl:test as part of a normal mvn package, etc.

This is purely noise in the log and doesn't indicate an actual error, so it can be safely ignored.

@niloc132 niloc132 added the bug Something isn't working label Jul 17, 2022
@niloc132 niloc132 added this to the 0.21 milestone Jul 17, 2022
@jiakuan
Copy link
Contributor

jiakuan commented Aug 30, 2023

Although it can be safely ignore, would there be a simple fix to ignore it from the plugin so that no such info printed after a successful build?

@jiakuan
Copy link
Contributor

jiakuan commented Aug 31, 2023

In a multi-project setup, many of the same stack track will be printed, which is a bit annoying.

@niloc132
Copy link
Member Author

It probably isn't a very hard fix, but I haven't prioritized it at this time - you're more than welcome to pick it up and contribute a fix?

jiakuan added a commit to jiakuan/j2clmavenplugin that referenced this issue Aug 31, 2023
@jiakuan
Copy link
Contributor

jiakuan commented Aug 31, 2023

Actually, I've already started looking into this, added a fix and tested locally. It seems working well.
Also, the Java version of J2CL Maven Archetypes can be upgraded to 11 according to my test, unless I missed something.

@jiakuan
Copy link
Contributor

jiakuan commented May 1, 2024

I still got lots of this kind of errors after build success. I added logs in DiskCache to see what the thread state was when the exception was thrown:

            State state = livenessThread.getState();
            if(!state.equals(Thread.State.TERMINATED)) {
                 throw new Error("ClosedWatchServiceException thrown, "
                     + "livenessThread state is: " + state, e);
            }

And found it could be RUNNABLE, TIMED_WAITING, BLOCKED:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  15.000 s
[INFO] Finished at: 2024-05-01T19:44:23+08:00
[INFO] ------------------------------------------------------------------------
Exception in thread "DiskCacheThread" java.lang.Error: ClosedWatchServiceException thrown, livenessThread state is: RUNNABLE
        at com.vertispan.j2cl.build.DiskCache.checkForWork(DiskCache.java:192)
        at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.nio.file.ClosedWatchServiceException
        at io.methvin.watchservice.AbstractWatchService.check(AbstractWatchService.java:94)
        at io.methvin.watchservice.AbstractWatchService.take(AbstractWatchService.java:86)
        at io.methvin.watchservice.MacOSXListeningWatchService.take(MacOSXListeningWatchService.java:38)
        at com.vertispan.j2cl.build.DiskCache.checkForWork(DiskCache.java:147)
        ... 1 more
Exception in thread "DiskCacheThread" java.lang.Error: ClosedWatchServiceException thrown, livenessThread state is: RUNNABLE
        at com.vertispan.j2cl.build.DiskCache.checkForWork(DiskCache.java:192)
        at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.nio.file.ClosedWatchServiceException
        at io.methvin.watchservice.AbstractWatchService.check(AbstractWatchService.java:94)
        at io.methvin.watchservice.AbstractWatchService.take(AbstractWatchService.java:86)
        at io.methvin.watchservice.MacOSXListeningWatchService.take(MacOSXListeningWatchService.java:38)
        at com.vertispan.j2cl.build.DiskCache.checkForWork(DiskCache.java:147)
        ... 1 more
Exception in thread "DiskCacheThread" java.lang.Error: ClosedWatchServiceException thrown, livenessThread state is: TIMED_WAITING
        at com.vertispan.j2cl.build.DiskCache.checkForWork(DiskCache.java:192)
        at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.nio.file.ClosedWatchServiceException
        at io.methvin.watchservice.AbstractWatchService.check(AbstractWatchService.java:94)
        at io.methvin.watchservice.AbstractWatchService.take(AbstractWatchService.java:86)
        at io.methvin.watchservice.MacOSXListeningWatchService.take(MacOSXListeningWatchService.java:38)
        at com.vertispan.j2cl.build.DiskCache.checkForWork(DiskCache.java:147)
        ... 1 more
Exception in thread "DiskCacheThread" Exception in thread "DiskCacheThread" java.lang.Error: ClosedWatchServiceException thrown, livenessThread state is: BLOCKED
        at com.vertispan.j2cl.build.DiskCache.checkForWork(DiskCache.java:192)
        at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.nio.file.ClosedWatchServiceException
        at io.methvin.watchservice.AbstractWatchService.check(AbstractWatchService.java:94)
        at io.methvin.watchservice.AbstractWatchService.take(AbstractWatchService.java:86)
        at io.methvin.watchservice.MacOSXListeningWatchService.take(MacOSXListeningWatchService.java:38)
        at com.vertispan.j2cl.build.DiskCache.checkForWork(DiskCache.java:147)
        ... 1 more
Exception in thread "DiskCacheThread" java.lang.Error: ClosedWatchServiceException thrown, livenessThread state is: RUNNABLE
        at com.vertispan.j2cl.build.DiskCache.checkForWork(DiskCache.java:192)
        at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.nio.file.ClosedWatchServiceException
        at io.methvin.watchservice.AbstractWatchService.check(AbstractWatchService.java:94)
        at io.methvin.watchservice.AbstractWatchService.take(AbstractWatchService.java:86)
        at io.methvin.watchservice.MacOSXListeningWatchService.take(MacOSXListeningWatchService.java:38)
        at com.vertispan.j2cl.build.DiskCache.checkForWork(DiskCache.java:147)
        ... 1 more
java.lang.Error: ClosedWatchServiceException thrown, livenessThread state is: RUNNABLE
        at com.vertispan.j2cl.build.DiskCache.checkForWork(DiskCache.java:192)
        at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.nio.file.ClosedWatchServiceException
        at io.methvin.watchservice.AbstractWatchService.check(AbstractWatchService.java:94)
        at io.methvin.watchservice.AbstractWatchService.take(AbstractWatchService.java:86)
        at io.methvin.watchservice.MacOSXListeningWatchService.take(MacOSXListeningWatchService.java:38)
        at com.vertispan.j2cl.build.DiskCache.checkForWork(DiskCache.java:147)
        ... 1 more
Exception in thread "DiskCacheThread" java.lang.Error: ClosedWatchServiceException thrown, livenessThread state is: RUNNABLE
        at com.vertispan.j2cl.build.DiskCache.checkForWork(DiskCache.java:192)
        at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.nio.file.ClosedWatchServiceException
        at io.methvin.watchservice.AbstractWatchService.check(AbstractWatchService.java:94)
        at io.methvin.watchservice.AbstractWatchService.take(AbstractWatchService.java:86)
        at io.methvin.watchservice.MacOSXListeningWatchService.take(MacOSXListeningWatchService.java:38)
        at com.vertispan.j2cl.build.DiskCache.checkForWork(DiskCache.java:147)
        ... 1 more
Exception in thread "DiskCacheThread" java.lang.Error: ClosedWatchServiceException thrown, livenessThread state is: TIMED_WAITING
        at com.vertispan.j2cl.build.DiskCache.checkForWork(DiskCache.java:192)
        at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.nio.file.ClosedWatchServiceException
        at io.methvin.watchservice.AbstractWatchService.check(AbstractWatchService.java:94)
        at io.methvin.watchservice.AbstractWatchService.take(AbstractWatchService.java:86)
        at io.methvin.watchservice.MacOSXListeningWatchService.take(MacOSXListeningWatchService.java:38)
        at com.vertispan.j2cl.build.DiskCache.checkForWork(DiskCache.java:147)
        ... 1 more

@niloc132
Copy link
Member Author

niloc132 commented May 1, 2024

Can you confirm which j2cl-maven-plugin version you are using?

@jiakuan
Copy link
Contributor

jiakuan commented May 2, 2024

I tried the latest 0.22.0 as well as the current main branch.
The exception stack I posted was from the current main (0.23-SNAPSHOT).

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants