use of java.nio.file.FileSystemAlreadyExistsException in project jimfs by google.
the class SystemJimfsFileSystemProvider method newFileSystem.
@Override
public FileSystem newFileSystem(URI uri, Map<String, ?> env) throws IOException {
checkArgument(uri.getScheme().equalsIgnoreCase(URI_SCHEME), "uri (%s) scheme must be '%s'", uri, URI_SCHEME);
checkArgument(isValidFileSystemUri(uri), "uri (%s) may not have a path, query or fragment", uri);
checkArgument(env.get(FILE_SYSTEM_KEY) instanceof FileSystem, "env map (%s) must contain key '%s' mapped to an instance of %s", env, FILE_SYSTEM_KEY, FileSystem.class);
FileSystem fileSystem = (FileSystem) env.get(FILE_SYSTEM_KEY);
if (fileSystems.putIfAbsent(uri, fileSystem) != null) {
throw new FileSystemAlreadyExistsException(uri.toString());
}
return fileSystem;
}
Aggregations