-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Describe the bug
Not really a bug. More a documentation issue, although some additional validation of azb: URI's might help.
The README for NIO documents the URI format as azb://?endpoint=storage-account-name.blob.core.windows.net. It's very easy to think you should create a URI of the form azb://container-name:/path/to/file?endpoint=... This is technically wrong because the container name is in the host name spot and not the first element of the path. However, this works, but only if the file being referenced is in the first container in the list of containers passed to the newFileSystem call when the Azure file system is initialized. The file system will happily create azb://second-container-name:/path/to/another/file?endpoint=... as a path, but that path won't work. It only works if the URI is of the form azb:/second-container-name:/path/to/another/file?endpoint=...
Code Snippet
Add the code snippet that causes the issue.
StorageSharedKeyCredential creds = new StorageSharedKeyCredential(keyconfig.get("accountname"),
keyconfig.get("accountkey"));
HashMap config = new HashMap();
config.put(AzureFileSystem.AZURE_STORAGE_SHARED_KEY_CREDENTIAL, creds);
config.put(AzureFileSystem.AZURE_STORAGE_FILE_STORES, azure_containers);
FileSystems.newFileSystem(new URI(String.format("azb://?endpoint=%s", azure_endpoint)),
where azure_containers is something like `"container1,container2"
Then:
path1 = Paths.get(new URI("azb://container1:/path/to/existing-file-in-container1"))
path1.exists() => true
but
path2 = Paths.get(new URI("azb://container2:/path/to/existing-file-in-container2"))
path2.exists() => false
whereas:
path2a = Paths.get(new URI("azb:/container2:/path/to/existing-file-in-container2"))
path2a.exists() => true
Expected behavior
Naively reading the docs for NIO, I'd expect both .exists tests to return true. If I use a single slash after the scheme, it works as expected, but the docs example shows 2 slashes. It does say that the container name has to be the first element of the URI path, but that's a little bit subtle. Some warning that double slashes after the azb: scheme are not needed, and could be harmful would be helpful.
Setup (please complete the following information):
- OS: Linux
- IDE: None
- Library/Libraries: azure-storage-blob-nio
- Java version: [e.g. 8] 8
- App Server/Environment: Clojure
- Frameworks: [None
I