8236246: SelectorProvider support for creating a DatagramChannel that is not interruptible
Alan Bateman
Alan.Bateman at oracle.com
Thu Dec 19 15:25:36 UTC 2019
This is an update to the SelectorProvider implementation with two
related parts to it:
1. The upcoming replacement of the DatagramSocket and MulticastSocket
implementations needs a socket adaptor that is not interruptible. It
also needs to be able to create it with built-in selector provider. This
part of the changes makes this easy with
DefaultSelectorProvider.get().openUninterruptibleDatagramChannel(). The
main difference between an interruptible and uninterruptible
DatagramChannel is that the hooks for Thread.interrupt aren't setup
around blocking operations, instead the uninterruptible case just needs
to check for async close at the end of blocking operations.
2. The second part is that SelectorProvider is specified to locate the
default provider when its "provider" method is first called. The current
implementation uses a lock to allow that initialization but it means
that the creation of all channels with the static factory methods (the
common case) ends up being synchronized. Moving the initialization of
the default provider to a holder class allows this lock to be removed.
The webrev with the changes is here. I've added a test to exercise the
(internal) openUninterruptibleDatagramChannel.
http://cr.openjdk.java.net/~alanb/8236246/webrev/
SAP folks - sun.nio.ch.DefaultSelectorProvider is changed but I have no
way to test the AIX change. I assume your testing will catch any issues
there.
-Alan
More information about the nio-dev
mailing list