You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
FileSystems.getFileSystem() throws a FileSystemNotFoundException if the file system has not been created before. This could be acceptable if FileSystems.newFileSystem(URI.create(file), new HashMap<>()) would be smart enough to return an existing FS if already created. Instead newFileSystem() throws a FileSystemAlreadyExistsException if called twice.
Alternatively, getFileSystem could return null, so to allow the pattern below (which now does not work):
FileSystem fs = FileSystems.getFileSystem(URI.create(file));
if (fs == null) {
fs = FileSystems.newFileSystem(URI.create(file), new HashMap<>());
}
Steps To Reproduce
see description
Expected Behavior
getFileSystem() returns a new FileSystem if not already created?
getFileSystem() returns null?
newFileSystem() returns an existing FS if already created?
Environment
s3fs-nio version: 1.0.0 (also 1.0.1)
The text was updated successfully, but these errors were encountered:
There is a bug left in some of the legacy code we've inherited. It was preventing an internal property's state to be visible from other threads and this messed up the getFileSystem method logic. I believe this should be fixed with #717. Could you try it out and let me know?
Your suggestion for returning null is not possible because it contradicts the java.nio.file.FileSystems#getFileSystem method's documentation:
Furthermore, the FileSystems method is a final one so we can't really change anything.
You can wrap your code in a try/catch that catches java.nio.file.ProviderNotFoundException instead of doing a null check and you'll achieve the same result :)
Bug Description
FileSystems.getFileSystem()
throws aFileSystemNotFoundException
if the file system has not been created before. This could be acceptable ifFileSystems.newFileSystem(URI.create(file), new HashMap<>())
would be smart enough to return an existing FS if already created. InsteadnewFileSystem()
throws aFileSystemAlreadyExistsException
if called twice.Alternatively, getFileSystem could return null, so to allow the pattern below (which now does not work):
Steps To Reproduce
see description
Expected Behavior
Environment
s3fs-nio
version:1.0.0
(also1.0.1
)The text was updated successfully, but these errors were encountered: