8274883: (se) Selector.open throws IAE when the default file system provider is changed to a custom provider#6722
8274883: (se) Selector.open throws IAE when the default file system provider is changed to a custom provider#6722mkartashev wants to merge 3 commits intoopenjdk:masterfrom
Conversation
…rovider is changed to a custom provider
|
👋 Welcome back mkartashev! A progress list of the required criteria for merging this PR into |
|
@mkartashev The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
AlanBateman
left a comment
There was a problem hiding this comment.
The JBS issue is assigned to @Michael-Mc-Mahon, might need to check if he already has a patch this for too.
| supported = init(); | ||
| } | ||
|
|
||
| static UnixDomainSocketAddress getUNNAMED() { |
There was a problem hiding this comment.
Can you rename this to unnamed() and move it up with the other package default static methods?
There was a problem hiding this comment.
Thanks for reviewing!
Renamed to unnamed().
| private UnixDomainSockets() { } | ||
|
|
||
| static final UnixDomainSocketAddress UNNAMED = UnixDomainSocketAddress.of(""); | ||
| private static class UNNAMEDHolder { |
There was a problem hiding this comment.
Let's rename this to UnamedHolder to avoid this strange class name.
| } catch (InvalidPathException e) { | ||
| throw new BindException("Invalid temporary directory"); | ||
| } catch (IllegalArgumentException e) { | ||
| throw new UnsupportedOperationException("Unix Domain Sockets not supported on non-default file system"); |
There was a problem hiding this comment.
There should be no need to catch IAE here, instead you can check the provider.
There was a problem hiding this comment.
Changed to if (path.getFileSystem().provider() != sun.nio.fs.DefaultFileSystemProvider.instance()) ...
I hope that was what you meant.
- renamed UNNAMEDHolder to UnnamedHolder, - renamed getUNNAMED() to unnamed(), - replaced catch IllegalArgumentException with a check for the provider.
|
@Michael-Mc-Mahon The issue is assigned to you? Are you okay if @mkartashev takes it? The updated src changes looks okay. test/jdk/java/nio/channels/Selector is probably the right location for the test as this issue is about the wakeup mechanism. I'd prefer to use a test name that is a bit more consistent with the naming in the area. Something like CustomFileSystem.java might be okay. We can also change the test to use Selector.open() as that is the user-facing API. I assume @library /test/lib can be dropped from the test description as the test doesn't use common test infrastructure. |
Michael-Mc-Mahon
left a comment
There was a problem hiding this comment.
Thanks for taking this on. I can sponsor it when we are finished with the review. Would it be possible to refer to the TestProvider in the SelectorProvider/spi directory in the @build directive, instead of copying it over to the Selector directory?
Thank you, much appreciated!
I looked for a way to do that, but couldn't find any. Besides, the new variant of the custom provider is much smaller and simpler than the "original" |
That's okay with me. It's useful to have it in the same directory anyway. I'm just running the patch through the test system here now. |
|
@mkartashev This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 33 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@AlanBateman, @Michael-Mc-Mahon) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
|
/integrate |
|
@mkartashev |
Michael-Mc-Mahon
left a comment
There was a problem hiding this comment.
Test results look normal apart from a couple of known intermittent issues
|
/sponsor |
|
Going to push as commit 7217cb7.
Your commit was automatically rebased without conflicts. |
|
@Michael-Mc-Mahon @mkartashev Pushed as commit 7217cb7. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
|
@Michael-Mc-Mahon @AlanBateman Thank you for your time! |
The gist of the problem: when a file system is specified via
-Djava.nio.file.spi.DefaultFileSystemProvider, a call toSelectorProvider.provider().openSelector()ends with a throw on Windows.There are two distinct components to the problem:
ExceptionInInitializerErroris thrown during the static initialization of theUnixDomainSockets.UNNAMEDfield even though it isn't used on this code path (seeUnixDomainSocketAddress.of()that throwsIllegalArgumentExceptionif invoked on a path from a non-default file system).This is fixed by lazy-initializing the static member
UNNAMEDofUnixDomainSocketsso that this initialization doesn't throw unless actually used.IllegalArgumentExceptionis thrown byUnixDomainSocketAddress.of()later on whenServerSocketChanneltries to use Windows version ofPipeImpland its methodcreateListener()specifically. ThatPipeImplprobes for the availability of Unix Domain Sockets by trying to bind to a unique temporary name. That call throwsIAEwhen a non-default Java file system is installed while the probing code (PipeImpl.createListener()) only expectsUnsupportedOperationExceptionorIOException.The fix is to re-throw
UOEinstead ofIAEinUnixDomainSockets.genrateTempName(). This is more consistent with the definition of the exception purpose ("requested operation is not supported"). So with this change, a loopback network socket will be used to implement a pipe on a non-default Java file system. Also, pipes do not rely on the default Java file system on other platforms (Linux, MacOS) as well.Tested by running
jtreg:test/jdk/java/nioon Window, MacOS, and Linux.Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/6722/head:pull/6722$ git checkout pull/6722Update a local copy of the PR:
$ git checkout pull/6722$ git pull https://git.openjdk.java.net/jdk pull/6722/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 6722View PR using the GUI difftool:
$ git pr show -t 6722Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/6722.diff