Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8274883

(se) Selector.open throws IAE when the default file system provider is changed to a custom provider

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 18
    • 16, 17
    • core-libs
    • None
    • b27
    • generic
    • windows

    Backports

      Description

        An attempt to use `SelectorProvider.provider().openSelector()` on Windows when the file system was specified via `-Djava.nio.file.spi.DefaultFileSystemProvider` fails with an exception starting with Java 16.

        To reproduce: on a Windows system, in the JDK root, go to `test/jdk/java/nio/file/spi`, compile `TestProvider.java` and this test class:
        ```
        import java.nio.channels.spi.SelectorProvider;
        public class UnixSocketInNonDefaultFS {
            public static void main(String args[]) throws java.io.IOException {
                    try {
                            SelectorProvider.provider().openSelector();
                    } catch(ExceptionInInitializerError e) {
                            e.getCause().printStackTrace();
                    }
            }
        }
        ```
        Executing `java -Djava.nio.file.spi.DefaultFileSystemProvider=TestProvider UnixSocketInNonDefaultFS` produces this output:
        ```
        java.lang.IllegalArgumentException
                at java.base/java.net.UnixDomainSocketAddress.of(UnixDomainSocketAddress.java:168)
                at java.base/java.net.UnixDomainSocketAddress.of(UnixDomainSocketAddress.java:146)
                at java.base/sun.nio.ch.UnixDomainSockets.<clinit>(UnixDomainSockets.java:47)
                at java.base/sun.nio.ch.SelectorProviderImpl.openServerSocketChannel(SelectorProviderImpl.java:101
        )
                at java.base/java.nio.channels.ServerSocketChannel.open(ServerSocketChannel.java:176)
                at java.base/sun.nio.ch.PipeImpl.createListener(PipeImpl.java:221)
                at java.base/sun.nio.ch.PipeImpl$Initializer$LoopbackConnector.run(PipeImpl.java:125)
                at java.base/sun.nio.ch.PipeImpl$Initializer.run(PipeImpl.java:83)
                at java.base/sun.nio.ch.PipeImpl$Initializer.run(PipeImpl.java:67)
                at java.base/java.security.AccessController.doPrivileged(AccessController.java:569)
                at java.base/sun.nio.ch.PipeImpl.<init>(PipeImpl.java:195)
                at java.base/sun.nio.ch.WEPollSelectorImpl.<init>(WEPollSelectorImpl.java:78)
                at java.base/sun.nio.ch.WEPollSelectorProvider.openSelector(WEPollSelectorProvider.java:33)
                at UnixSocketInNonDefaultFS.main(UnixSocketInNonDefaultFS.java:15)
        ```

        Doing the same with JDK11 produces no such exception.

        The problem seems to be in the early bail-out during the static initialization of the `UnixDomainSockets.UNNAMED` field even though it isn't used on this code path.

        Attachments

          Issue Links

            Activity

              People

                michaelm Michael McMahon
                mkartashev Maxim Kartashev
                Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: