Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support system.setProperty style overriding of default provider #41

Open
Groostav opened this issue Oct 21, 2016 · 0 comments
Open

support system.setProperty style overriding of default provider #41

Groostav opened this issue Oct 21, 2016 · 0 comments
Labels
P4 type=enhancement Make an existing feature better

Comments

@Groostav
Copy link

Groostav commented Oct 21, 2016

As a user writing a suite of unit tests against a file-IO heavy application, I would like to simply set the default file system provider via a call similar to System.setProperty("java.nio.file.spi.DefaultFileSystemProvider", "com.google.common.jimfs.SystemJimfsFileSystemProvider"), so that I can more easily apply JimFS as the systems file system.

So this is hopefully a fairly minor request:

the system property "java.nio.file.spi.DefaultFileSystemProvider" controls which FileSystemProvider is to be used as the default one. It works by specifying a fully-qualified class name as the value, which will be loaded on a call to java.nio.file.FileSystems.DefaultFileSystemHolder#getDefaultProvider. It does this by looking for a constructor that takes a FileSystemProvider as its single argument, effectively allowing you to chain-wrap file system providers.

So, if you guys could add another constructor to the SystemFileSystemProvider, that takes a provider as an argument and simply ignores it, I would be much appreciative.

Regarding

I'd strongly recommend not using Paths.get to get a Path in your production code. It's convenient as a quick replacement for new File(String) when migrating from the old API, but that's about it. When using java.nio.file, methods that tie you to the default FileSystem are generally an anti-pattern.

I agree with the general principal but I'd appreciate a little trust in navigating this space myself. I think this is better expressed as a line in documentation rather than a hard requirement within your library.

In my particular case, some of my libraries are calling Paths.get() and the application I'm building is quite small, so I'm OK with using statics for testing here.

This issue relates to:

@cpovirk cpovirk added type=enhancement Make an existing feature better P4 labels Jul 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P4 type=enhancement Make an existing feature better
Projects
None yet
Development

No branches or pull requests

2 participants