[
https://issues.apache.org/jira/browse/PHOENIX-7537?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17932517#comment-17932517
]
Istvan Toth commented on PHOENIX-7537:
--------------------------------------
IMO no.
The normalized URL is returned by the toUrl() method.
If for some reason you want to use getZkHosts (and you don't need the other URL
components), then you need to escape the colons, and add the JDBC URL prefix.
> Well formed URLs created by ZKConnectionInfo.create() throw Malformed
> connection url exception.
> -----------------------------------------------------------------------------------------------
>
> Key: PHOENIX-7537
> URL: https://issues.apache.org/jira/browse/PHOENIX-7537
> Project: Phoenix
> Issue Type: Bug
> Reporter: Jacob Isaac
> Priority: Major
>
> @Test
> public void testMalformedZKConnection() throws SQLException {
> Configuration config =
> HBaseFactoryProvider.getConfigurationFactory().getConfiguration();
> String defaultQuorum = config.get(HConstants.ZOOKEEPER_QUORUM);
> for (String protocol : new String[] \{ "phoenix", "phoenix+zk" }) {
> String[] urls = new String[] {
> "v1,v2,v3:2181:/hbase",
> "jdbc:" + protocol + ":localhost",
> "jdbc:" + protocol + ":localhost:2181,localhost:12181:/hbase",
> "jdbc:" + protocol + ":v1,v2,v3:2181:/hbase",
> };
> for (String url : urls) {
> try {
> ZKConnectionInfo
> info =
> (ZKConnectionInfo) ConnectionInfo.create(url, null, null);
> System.out.println("1.Successfully connected to " + url + " , " +
> info.getZkHosts());
> {color:#FF0000}*// Passing the normalized url (info.getZkHosts()) from above
> again into Connection.create fails*{color}
> {color:#FF0000}*// for some formats.*{color}
> ZKConnectionInfo
> info2 =
> (ZKConnectionInfo) ConnectionInfo.create(info.getZkHosts(), null, null);
> System.out.println("2.Successfully connected to " + url + " , " +
> info.getZkHosts());
> } catch (SQLException sqle) {
> System.out.println(sqle.getMessage());
> }
> }
> }
> }
--
This message was sent by Atlassian Jira
(v8.20.10#820010)