java.nio.channels.MembershipKey API

Alan Bateman Alan.Bateman at Sun.COM
Thu Nov 27 01:06:58 PST 2008


David M. Lloyd wrote:
> Ressurrecting this old thread - I have one additional comment about 
> the MembershipKey interface.  Rather than have drop()/isValid(), why 
> not extend Channel (or at least Closeable) and have close()/isOpen() 
> instead?  This way any code which has a common resource cleanup 
> mechanism based on Closeable will be able to clean up MembershipKeys 
> in the same way.
>
> - DML
For resource cleanup, I would expect the multicast channel to be 
registered for close rather than the membership keys. When the multicast 
channel is closed then it drops membership of all groups and invalidates 
all keys. Looking at the javadoc again, I see that this isn't as clear 
as it should. There is wording in MembershipKey to require the key to be 
invalidated when the channel is closed but we don't have wording in 
MulticsatChannel to make it clear that membership is dropped when the 
channel is closed - I will fix that (thanks!). With that fixed, I am 
happy with "drop" (same thing in FileLock with the "release" method).

-Alan.



More information about the nio-dev mailing list