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
Inconsistent behavior in Files.exists() #859
Comments
I found this note in the docs
https://www.mvndoc.com/c/com.google.cloud/gcloud-java-nio/index.html This seems to be the reasoning behind why |
@sydney-munro Ah, thanks for diving for that! From that description it's not clear though that just |
It sounds like it would be a change of behavior, but I would expect Files.exist() to return false on any file in a bucket that doesn't exist, (or the bucket itself), even if it ends in a |
I agree, it has to do with when we probe to actually see if we can perform I/O, but yes ultimately we should be returning some sort of error such as a FileSystemNotFoundException. Give me until tomorrow to sort out a path forward for handling this more appropriately. |
Thank you for looking into it! I think we would definitely appreciate it returning Other cases like "can't determine if the file exists because you lack permissions" are obviously a different case. |
Thats understandable. Our concern is deviating from what would be standard behavior. For example if a file does not exist Whereas we believe FileSystemNotFoundException is more appropriate. |
Apologies on the delay of getting back to this. So I have gone through the code and thought about the options.
This returns true:
This is mainly to stay consistent with my initial comment however i do find that confusing. I would much prefer to return FileSystemNotFoundException for all of these cases |
lbergelson apologies on the back and forth here. I spoke with the team and you also mentioned some similar concerns on my approach of using CloudStorageFileSystemProvider.getPath to check the existence of a bucket regarding lifecycle and the possibility of changing state while the program runs placing us in the same position as before with an unintended storage exception. Given this we will not be reworking the behavior and rather manage wrapping the storage exception in something more appropriate. We will continue to have these return true, and update the documentation to be more clear.
This case will be handled to throw an appropriate error.
|
Files.exists(gsPath) will sometimes throw an exception when a Path uses a bucket that doesn't exist.
Otherwise it returns
true
if the bucket doesn't exist. It seems like it should returnfalse
.The truthyness depends on the psuedoDirectory settings.
Environment details
Steps to reproduce
Code example
It crashes only when there isn't a trailing
/
because of an inconsistency in the way the pseudo directories are handled.Stack trace
Any additional information below
Following these steps guarantees the quickest resolution possible.
Thanks!
The text was updated successfully, but these errors were encountered: