Fix oracle url parser ignoring actual port (#456)
* Fix oracle url parser missed case * Add changelog
This commit is contained in:
parent
9cb5a13d44
commit
5250ecfe2e
|
|
@ -14,6 +14,7 @@ Release Notes.
|
|||
* Refactor pipeline in jedis-plugin.
|
||||
* Enhance kotlin coroutine plugin for stack tracing.
|
||||
* Add plugin to support ClickHouse JDBC driver (0.3.2.*).
|
||||
* Fix OracleURLParser ignoring actual port when :SID is absent.
|
||||
|
||||
#### Documentation
|
||||
* Update docs of Tracing APIs, reorganize the API docs into six parts.
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ import org.apache.skywalking.apm.util.StringUtil;
|
|||
/**
|
||||
* {@link OracleURLParser} presents that how to parse oracle connection url.
|
||||
* <p>
|
||||
* Note: {@link OracleURLParser} can parse the commons connection url. the commons connection url is of the form:
|
||||
* <code>jdbc:oracle:(drivertype):@(database)</code>,the other the form of connection url cannot be parsed success.
|
||||
* Note: {@link OracleURLParser} can parse the commons/TNS connection url. the commons connection url is of the form:
|
||||
* <code>jdbc:oracle:(drivertype):@(database)</code>, the other the form of connection url cannot be parsed successfully.
|
||||
*/
|
||||
public class OracleURLParser extends AbstractURLParser {
|
||||
|
||||
|
|
@ -49,7 +49,14 @@ public class OracleURLParser extends AbstractURLParser {
|
|||
} else {
|
||||
hostLabelStartIndex = url.indexOf("@") + 1;
|
||||
}
|
||||
int hostLabelEndIndex = url.lastIndexOf(":");
|
||||
|
||||
String urlTrimmed = url.substring(hostLabelStartIndex);
|
||||
|
||||
// When /service/<property> exists, check the first slash in trimmed url
|
||||
// otherwise use the last colon to locate the port number
|
||||
int hostLabelEndIndex = urlTrimmed.contains("/") ?
|
||||
hostLabelStartIndex + urlTrimmed.indexOf("/") : url.lastIndexOf(":");
|
||||
|
||||
return new URLLocation(hostLabelStartIndex, hostLabelEndIndex);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -99,10 +99,10 @@ public class URLParserTest {
|
|||
|
||||
@Test
|
||||
public void testParseOracleServiceName() {
|
||||
ConnectionInfo connectionInfo = new URLParser().parser("jdbc:oracle:thin:@//localhost:1521/orcl");
|
||||
ConnectionInfo connectionInfo = new URLParser().parser("jdbc:oracle:thin:@//localhost:1531/orcl");
|
||||
assertThat(connectionInfo.getDBType(), is("Oracle"));
|
||||
assertThat(connectionInfo.getDatabaseName(), is("orcl"));
|
||||
assertThat(connectionInfo.getDatabasePeer(), is("localhost:1521"));
|
||||
assertThat(connectionInfo.getDatabasePeer(), is("localhost:1531"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
Loading…
Reference in New Issue