gmethvin / directory-watcher

A cross-platform Java recursive directory watcher, with a JNA macOS watcher and Scala better-files integration
Apache License 2.0
265 stars 34 forks source link

IllegalStateException: Queue full #5

Closed francisdb closed 6 years ago

francisdb commented 6 years ago

this is on a rather big multiproject sbt build

JNA: Callback io.methvin.watchservice.MacOSXListeningWatchService$MacOSXListeningCallback@4778113f threw the following exception:
java.lang.IllegalStateException: Queue full
    at java.util.AbstractQueue.add(AbstractQueue.java:98)
    at java.util.concurrent.ArrayBlockingQueue.add(ArrayBlockingQueue.java:312)
    at io.methvin.watchservice.AbstractWatchKey.signalEvent(AbstractWatchKey.java:156)
    at io.methvin.watchservice.MacOSXListeningWatchService$MacOSXListeningCallback.invoke(MacOSXListeningWatchService.java:171)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.sun.jna.CallbackReference$DefaultCallbackProxy.invokeCallback(CallbackReference.java:485)
    at com.sun.jna.CallbackReference$DefaultCallbackProxy.callback(CallbackReference.java:515)
    at com.sun.jna.Native.invokeVoid(Native Method)
    at com.sun.jna.Function.invoke(Function.java:374)
    at com.sun.jna.Function.invoke(Function.java:323)
    at com.sun.jna.Library$Handler.invoke(Library.java:236)
    at com.sun.proxy.$Proxy11.CFRunLoopRun(Unknown Source)
    at io.methvin.watchservice.MacOSXListeningWatchService$CFRunLoopThread.run(MacOSXListeningWatchService.java:105)
gmethvin commented 6 years ago

Do you have a reproducer? What kind of changes trigger this error?

francisdb commented 6 years ago

just a ~test:compile on the root of a big project (20+ subprojects)

using the MacOSXWatchService sbt plugin

gmethvin commented 6 years ago

Okay I see the bug. We should be calling queue.offer instead of queue.add. If the offer is rejected we can send an OVERFLOW event. It also probably wouldn't hurt to make the queue size configurable.

fsvehla commented 6 years ago

@francisdb The ‘MacOSXWatchService’ is this project? https://github.com/megri/macos-watcher That doesn’t seem to use this library though.

gmethvin commented 6 years ago

It is https://github.com/swoval/MacOSXWatchService. Looks like the author has copied the code from this project and made some changes.