Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,9 @@ public void initialize(final URI theUri, final Configuration conf)
tableName = theUri.getHost();
}
try {
myUri = new URI(getScheme(), authority, "/", null, null);
myUri = (authority != null) ?
new URI(getScheme(), authority, null, null, null) :
new URI(getScheme(), null, "/", null, null);
boolean initingUriAsFallbackOnNoMounts =
supportAutoAddingFallbackOnNoMounts();
fsState = new InodeTree<FileSystem>(conf, tableName, myUri,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void setUp() throws Exception {
// Now create a viewfs using a mount table called "default"
// hence viewfs://default/
schemeWithAuthority =
new URI(FsConstants.VIEWFS_SCHEME, "default", "/", null, null);
new URI(FsConstants.VIEWFS_SCHEME, "default", null, null, null);
fsView = FileSystem.get(schemeWithAuthority, conf);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1515,4 +1515,17 @@ public void testTargetFileSystemLazyInitializationForChecksumMethods()
// viewfs inner cache is disabled
assertEquals(cacheSize + 1, TestFileUtil.getCacheSize());
}

@Test
public void testGetURI() throws Exception {
// test that URIs without authority return the path component.
URI viewFsWithoutAuthority = URI.create("viewfs:///");
FileSystem fs = FileSystem.get(viewFsWithoutAuthority, conf);
assertEquals(viewFsWithoutAuthority, fs.getUri());

// test that URIs with authority do not return the path component.
URI viewFsWithAuthority = URI.create("viewfs://default");
fs = FileSystem.get(viewFsWithAuthority, conf);
assertEquals(viewFsWithAuthority, fs.getUri());
}
}