steveloughran commented on a change in pull request #1621: HADOOP-16640. WASB: Override getCanonicalServiceName() to return URI URL: https://github.com/apache/hadoop/pull/1621#discussion_r334862383
########## File path: hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/ITestWasbUriAndConfiguration.java ########## @@ -640,4 +640,28 @@ public void testUserAgentConfig() throws Exception { FileSystem.closeAll(); } } + + @Test + public void testCanonicalServiceName() throws Exception { + AzureBlobStorageTestAccount testAccount = AzureBlobStorageTestAccount.createMock(); + Configuration conf = testAccount.getFileSystem().getConf(); + String authority = testAccount.getFileSystem().getUri().getAuthority(); + URI defaultUri = new URI("wasbs", authority, null, null, null); + conf.set(FS_DEFAULT_NAME_KEY, defaultUri.toString()); + + final FileSystem fs0 = FileSystem.get(conf); + // Default getCanonicalServiceName() will try to resolve the host to IP, + // because the mock container does not exist, this call is expected to fail. + intercept(IllegalArgumentException.class, + "java.net.UnknownHostException", + ()-> { + fs0.getCanonicalServiceName(); + }); + + // clear fs cache + FileSystem.closeAll(); Review comment: you don't need to do that , just call `FileSystem.newInstance(defaultURI, conf)`, remembering to close the new FS afterwards ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-issues-h...@hadoop.apache.org