Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
While working on a related project, I realized that it's essential to handle the OVERFLOW case for a WatchEvent. The EventMonitor relies on subdirectory creation events to create a new watch key for each subdirectory. If those events are missed due to overflow, the EventMonitor will not be monitoring the newly created subdirectories. To fix this, when the EventMonitor detects an overflow, it will now poll the directory of the watch key repeatedly until it stabilizes. Once that happens, it will register all of the newly found directories (if any) with the watch service and will create events for all of the files in said directories. It is still possible that a trigger could be missed in the event that a lot of files in a watched directory cause an overflow before a valid source file is touched and before the EventMonitor handles the overflow. I am not particularly worried about this. I also discovered that the PollingWatchService was using an unbounded list of events. This seemed risky so I switched to using an ArrayBlockingQueue of size 256, which is what the MacOSXWatchService uses as well. Since the queue is now bounded, I added overflow events to the PollingWatchService as well. I also added synchronization for a few methods in PollingWatchey and MacOSXWatchKey. This is more consistent with the AbstractWatchKey in the jdk. The other methods return constant values so synchronization is pointless. I ran a number of travis builds against the content of this commit and none of them failed.
- Loading branch information
Showing
7 changed files
with
143 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters