gmethvin/directory-watcher

IllegalStateException: Queue full

francisdb opened this issue · 5 comments

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)

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

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

using the MacOSXWatchService sbt plugin

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.

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

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