Fix Impala Jdbc URL (including schema without properties) parsing exception (#644)
This commit is contained in:
parent
d5cfd35c5d
commit
2721438820
|
|
@ -18,6 +18,7 @@ Release Notes.
|
|||
* Support collecting ZGC memory pool metrics. Require OAP 9.7.0 to support these new metrics.
|
||||
* Upgrade netty-codec-http2 to 4.1.100.Final
|
||||
* Add a netty-http 4.1.x plugin to trace HTTP requests.
|
||||
* Fix Impala Jdbc URL (including schema without properties) parsing exception.
|
||||
|
||||
|
||||
#### Documentation
|
||||
|
|
|
|||
|
|
@ -36,6 +36,9 @@ public class ImpalaJdbcURLParser extends AbstractURLParser {
|
|||
protected URLLocation fetchDatabaseHostsIndexRange() {
|
||||
int hostLabelStartIndex = url.indexOf("//");
|
||||
int hostLabelEndIndex = url.length();
|
||||
if (url.indexOf("/", hostLabelStartIndex + 2) != -1) {
|
||||
hostLabelEndIndex = url.indexOf("/", hostLabelStartIndex + 2);
|
||||
}
|
||||
int hostLabelEndIndexWithParameter = url.indexOf(";", hostLabelStartIndex);
|
||||
if (hostLabelEndIndexWithParameter != -1) {
|
||||
String subUrl = url.substring(0, hostLabelEndIndexWithParameter);
|
||||
|
|
@ -64,6 +67,9 @@ public class ImpalaJdbcURLParser extends AbstractURLParser {
|
|||
if (databaseStartTag == -1 && firstParamIndex == -1) {
|
||||
return null;
|
||||
} else {
|
||||
if (firstParamIndex == -1) {
|
||||
firstParamIndex = url.length();
|
||||
}
|
||||
String subUrl = url.substring(startSize, firstParamIndex);
|
||||
int schemaIndex = subUrl.indexOf("/");
|
||||
if (schemaIndex == -1) {
|
||||
|
|
|
|||
|
|
@ -185,4 +185,26 @@ public class URLParserTest {
|
|||
assertThat(connectionInfo.getDatabasePeer(), is("localhost:8123"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseImpalaJDBCURL() {
|
||||
ConnectionInfo connectionInfo = new URLParser().parser("jdbc:impala://localhost:21050/test;AuthMech=3;UID=UserName;PWD=Password");
|
||||
assertThat(connectionInfo.getDBType(), is("Impala"));
|
||||
assertThat(connectionInfo.getDatabaseName(), is("test"));
|
||||
assertThat(connectionInfo.getDatabasePeer(), is("localhost:21050"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseImpalaJDBCURLWithSchema() {
|
||||
ConnectionInfo connectionInfo = new URLParser().parser("jdbc:impala://localhost:21050/test");
|
||||
assertThat(connectionInfo.getDBType(), is("Impala"));
|
||||
assertThat(connectionInfo.getDatabaseName(), is("test"));
|
||||
assertThat(connectionInfo.getDatabasePeer(), is("localhost:21050"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseImpalaJDBCURLWithoutSchema() {
|
||||
ConnectionInfo connectionInfo = new URLParser().parser("jdbc:impala://localhost:21050");
|
||||
assertThat(connectionInfo.getDBType(), is("Impala"));
|
||||
assertThat(connectionInfo.getDatabasePeer(), is("localhost:21050"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue