Skip to content
This repository has been archived by the owner. It is now read-only.

8259028: ClassCastException when using custom filesystem with wrapper FileChannel impl #90

Closed
wants to merge 3 commits into from

Conversation

@mcimadamore
Copy link
Contributor

@mcimadamore mcimadamore commented Jan 6, 2021

This patch tweaks MemorySegment::mapFile so that it will throw IllegalArgumentException whenever the path to be mapped is associated with a custom file system provider.

The check in the implementation is heavily borrowed by what UnixDomainSocketAddress::of(Path) does (thanks Alan for the tip!). Not only we have to check if file system is the default one, but also if the default FS belongs to java.base (since that can be overridden).

The test simply check that paths coming from the (internal) JRT file system are not supported by the factory.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8259028: ClassCastException when using custom filesystem with wrapper FileChannel impl

Reviewers

Download

$ git fetch https://git.openjdk.java.net/jdk16 pull/90/head:pull/90
$ git checkout pull/90

@mcimadamore
Copy link
Contributor Author

@mcimadamore mcimadamore commented Jan 6, 2021

/csr needed

@mcimadamore
Copy link
Contributor Author

@mcimadamore mcimadamore commented Jan 6, 2021

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Jan 6, 2021

👋 Welcome back mcimadamore! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

@openjdk openjdk bot commented Jan 6, 2021

@mcimadamore this pull request will not be integrated until the CSR request JDK-8259321 for issue JDK-8259028 has been approved.

@openjdk
Copy link

@openjdk openjdk bot commented Jan 6, 2021

@mcimadamore The following label will be automatically applied to this pull request:

  • core-libs

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.

@openjdk openjdk bot added the core-libs label Jan 6, 2021
@mlbridge
Copy link

@mlbridge mlbridge bot commented Jan 6, 2021

Webrevs

Copy link
Member

@uschindler uschindler left a comment

Looks fine to me.

Another option would have been to just check the class with instanceof. If the FileChannel returned by the path's filesystem has wrong type, it won't work. If we have some custom filesystem that just returns the original FileChannelImpl but does some additional checks before or after (e.g to hide some files from user), this would still work.

But I think it's better to be clear here and deny anything which is not default operating system filesystem, until we have a better solution.

In Lucene I added some hack that removes our test-only filesystem wrappers from the path. I will later go the route to mark those path instances with some interface Unwrappable that provides a method unwrap().

@mcimadamore
Copy link
Contributor Author

@mcimadamore mcimadamore commented Jan 6, 2021

Another option would have been to just check the class with instanceof. If the FileChannel returned by the path's filesystem has wrong type, it won't work. If we have some custom filesystem that just returns the original FileChannelImpl but does some additional checks before or after (e.g to hide some files from user), this would still work.

We considered this - but we opted for better clarity and alignment with existing APIs.

@mcimadamore
Copy link
Contributor Author

@mcimadamore mcimadamore commented Jan 11, 2021

/integrate

@openjdk
Copy link

@openjdk openjdk bot commented Jan 11, 2021

@mcimadamore This PR has not yet been marked as ready for integration.

@mcimadamore
Copy link
Contributor Author

@mcimadamore mcimadamore commented Jan 11, 2021

/csr unneeded

@openjdk openjdk bot removed the csr label Jan 11, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Jan 11, 2021

@mcimadamore determined that a CSR request is not needed for this pull request.

@openjdk
Copy link

@openjdk openjdk bot commented Jan 11, 2021

@mcimadamore 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:

8259028: ClassCastException when using custom filesystem with wrapper FileChannel impl

Reviewed-by: chegar, alanb, uschindler

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 16 new commits pushed to the master branch:

  • e05f36f: 8259043: More Zero architectures need linkage with libatomic
  • 020ec84: 8259429: Update reference to README.md
  • fb68395: 8259014: (so) ServerSocketChannel.bind(UnixDomainSocketAddress)/SocketChannel.bind(UnixDomainSocketAddress) will have unknown user and group owner (win)
  • 677802d: 8258484: AIX build fails in Harfbuzz with XLC 16.01.0000.0006
  • 1973fbe: 8039278: console.sh failed Automatically with exit code 1
  • acdd90b: 8258972: unexpected compilation error with generic sealed interface
  • c1fb521: 8259227: C2 crashes with SIGFPE due to a division that floats above its zero check
  • 484e23b: 8258657: Doc build is broken by use of new language features
  • 4a478b8: 8250903: jdk/jfr/javaagent/TestLoadedAgent.java fails with Mismatch in TestEvent count
  • 4f914e2: 8249633: doclint reports missing javadoc for JavaFX property methods that have a property description
  • ... and 6 more: https://git.openjdk.java.net/jdk16/compare/80110dac91767b01de35c583af7b370a36a03c18...master

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.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready label Jan 11, 2021
@mcimadamore
Copy link
Contributor Author

@mcimadamore mcimadamore commented Jan 11, 2021

/integrate

@openjdk openjdk bot closed this Jan 11, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels Jan 11, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Jan 11, 2021

@mcimadamore Since your change was applied there have been 16 commits pushed to the master branch:

  • e05f36f: 8259043: More Zero architectures need linkage with libatomic
  • 020ec84: 8259429: Update reference to README.md
  • fb68395: 8259014: (so) ServerSocketChannel.bind(UnixDomainSocketAddress)/SocketChannel.bind(UnixDomainSocketAddress) will have unknown user and group owner (win)
  • 677802d: 8258484: AIX build fails in Harfbuzz with XLC 16.01.0000.0006
  • 1973fbe: 8039278: console.sh failed Automatically with exit code 1
  • acdd90b: 8258972: unexpected compilation error with generic sealed interface
  • c1fb521: 8259227: C2 crashes with SIGFPE due to a division that floats above its zero check
  • 484e23b: 8258657: Doc build is broken by use of new language features
  • 4a478b8: 8250903: jdk/jfr/javaagent/TestLoadedAgent.java fails with Mismatch in TestEvent count
  • 4f914e2: 8249633: doclint reports missing javadoc for JavaFX property methods that have a property description
  • ... and 6 more: https://git.openjdk.java.net/jdk16/compare/80110dac91767b01de35c583af7b370a36a03c18...master

Your commit was automatically rebased without conflicts.

Pushed as commit d60a937.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
4 participants