WatchService re-register events appended or replaced

Alan Bateman Alan.Bateman at oracle.com
Wed Jul 25 21:11:51 PDT 2012


On 26/07/2012 00:13, Michael Hall wrote:
> This isn't clear to me from the javadoc which I thought might make it worth raising the question even if I could track down the answer myself.
> When you re-register a path you should get the same WatchKey back. Does it keep it's old events and get the new ones added?
> I assume re-register amounts to an event reset but would feel safer in this assumption with some confirmation?
>
I think this is all covered in the javadoc (register method):

"If the file system object identified by this object is currently 
registered with the watch service then the watch key, representing that 
registration, is returned after changing the event set or modifiers to 
those specified by the |events| and |modifiers| parameters. Changing the 
event set does not cause pending events for the object to be discarded. "

So calling register on an object that is already registered does change 
the event set but it doesn't discard events that are waiting to be 
retrieved. Hopefully this helps.

-Alan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20120726/f2a0529a/attachment.html 


More information about the nio-dev mailing list