Skip to content
Draft
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 @@ -760,8 +760,9 @@ DBInfo.Builder doParse(final String jdbcUrl, final DBInfo.Builder builder) {

if (portLoc > 0) {
hostEndLoc = portLoc;
final int portEndLoc = dbLoc > 0 ? dbLoc : (paramLoc > 0 ? paramLoc : details.length());
try {
builder.port(Integer.parseInt(details.substring(portLoc + 1, dbLoc)));
builder.port(Integer.parseInt(details.substring(portLoc + 1, portEndLoc)));
} catch (final NumberFormatException ignored) {
}
} else if (dbLoc > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ class JDBCConnectionUrlParserTest extends InstrumentationSpecification {
"jdbc:jtds:sqlserver://dbhostname.com;user=user;password=pw" | null | "jtds" | "sqlserver" | "user" | "dbhostname.com" | 1433 | null | null
"jdbc:jtds:sqlserver://dbhostname.com" | null | "jtds" | "sqlserver" | null | "dbhostname.com" | 1433 | null | null
"jdbc:jtds:sybase://dbhostname.com" | null | "jtds" | "sybase" | null | "dbhostname.com" | 7100 | null | null
// host:port with no trailing '/db' and no ';' params (regression: StringIndexOutOfBoundsException)
"jdbc:jtds:sqlserver://dbhostname.com:1433" | null | "jtds" | "sqlserver" | null | "dbhostname.com" | 1433 | null | null
"jdbc:jtds:sqlserver://dbhostname.com:1433;user=user;password=pw" | null | "jtds" | "sqlserver" | "user" | "dbhostname.com" | 1433 | null | null

// redshift
"jdbc:redshift://redshift-cluster-1.c7arcolffyvk.us-east-2.redshift.amazonaws.com:5439/dev" | null | "redshift" | null | null | "redshift-cluster-1.c7arcolffyvk.us-east-2.redshift.amazonaws.com" | 5439 | "redshift-cluster-1" | "dev"
Expand Down