-
Notifications
You must be signed in to change notification settings - Fork 9
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
Paths.getPath() not working #14
Comments
@stefanofornari are you sure you're using the right library? I can get the same error only by not adding sftp-fs to the class or module path, and using a URI that starts "sftp://". However, I think the issue you're describing is still valid, because if I do add sftp-fs, I get the following message:
I could change the code so that Another disadvantage of automatically creating file systems is resource management. If a file system is explicitly created, callers know that they need to close it. Who's going to close automatically created file systems? Would you think of calling |
Note that the creation of the file system doesn't have to be located anywhere near the retrieval of |
Hi @robtimus , thanks for looking into it and sorry for the not accurate description, I missed up with different tests. I fixed it. Back to the topic, yes, I believe you should provide the possibility that the most basic information is provided through the URL (e.g. credentials). If you want to avoid that by mistake credentials are exposed for example in a toString() I recommend to not include credentials information in your SFTPPath.toUri() and toString() implementation. You have definitely a point about more complex configuration. I believe this is a flaw in current NIO FS architecture that can be worked around through system properties, property files or query string depending on the complexity you need to afford. However keep in mind the final goal is like the following use case: let's say we implement ls in java, let's say jls, which shows the content of a directory based on NIO FS. The users of our jls should be able to just add a jar in the class path and issue the command:
This should work out of the box because those users will not have the option to compile the command to add your initialization code. HTH PS1: please also note that PS2: I have noticed you have to repositories for ftp and sftp; is there a reason? |
I still have to think about how to properly handle your case. Using anonymous access or possibly by providing credentials through the URI would solve some issues, but additional configuration can become complex, even using system properties or a query string, especially for values that cannot be easily be converted to and from strings. Perhaps a way to provide system-wide defaults could work, but that would need to be made thread-safe. Regarding PS1: Regarding PS2: FTP and FTPs are completely different from SFTP, which uses SSH. |
Ah, cool! |
I do not think this is "my case", it is the way users expect a NIO File System to work (you can check other implementations as well). IMHO you should follow th 80-20 rule: 80% of the users will most likely be fine with simple configuration on the URL. The remaining 20%, can use newFileSystem() directly, which is anyway part of the interface, |
The Javadoc says that throwing a |
I am not sure why you are so much concerned about it, and again: you would not create a file system without authentication or configuration, you have to use the URI for it. Actually, authentication is even embedded in the URI object, you do not even have to care about it. For the configuration, what we said before is still valid. BTW, it is how JDBC works and again, check other NIO file systems for reference. |
For the simple case where you authenticate with a username/password combination this could work yes, but out of all servers I communicate with over HTTP, only a small number uses that. All of the others use key pairs, using ssh-agent or PuTTY's pageant. Without any additional configuration that wouldn't be possible right now. |
And for those, in step one, users will have to use newFileSystem() like they do today.
I am not very familiar with that, but I tent to believe a property file will solve the issue in 80% of cases. |
I've just released version 3.3 which improves both |
To reproduce:
Paths.get(URI.create("sftp://somewhere.com));
Expected:
As per NIO FileSystem behaviour get() should create a file system and return a path
Actual:
Reading the readme I understand that the FS should be created before calling Paths.get(), but this does not make much sense IMHO for the following reasons:
The text was updated successfully, but these errors were encountered: