Fix parsing port from mariadb jdbc url (#9863)
This commit is contained in:
parent
23b2521c43
commit
c973b9ebd4
|
@ -322,7 +322,7 @@ public enum JdbcConnectionUrlParser {
|
|||
int clusterSepLoc = jdbcUrl.indexOf(",");
|
||||
int ipv6End = jdbcUrl.startsWith("[") ? jdbcUrl.indexOf("]") : -1;
|
||||
int portLoc = jdbcUrl.indexOf(":", Math.max(0, ipv6End));
|
||||
portLoc = clusterSepLoc < portLoc ? -1 : portLoc;
|
||||
portLoc = clusterSepLoc != -1 && clusterSepLoc < portLoc ? -1 : portLoc;
|
||||
int dbLoc = jdbcUrl.indexOf("/", Math.max(portLoc, clusterSepLoc));
|
||||
|
||||
int paramLoc = jdbcUrl.indexOf("?", dbLoc);
|
||||
|
|
|
@ -89,6 +89,7 @@ class JdbcConnectionUrlParserTest extends Specification {
|
|||
"jdbc:mariadb:failover://mdb.host1:33,mdb.host/mdbdb?characterEncoding=utf8" | null | "mariadb:failover://mdb.host1:33" | "mariadb" | "failover" | null | "mdb.host1" | 33 | null | "mdbdb"
|
||||
"jdbc:mariadb:sequential://mdb.host1,mdb.host2:33/mdbdb" | null | "mariadb:sequential://mdb.host1:3306" | "mariadb" | "sequential" | null | "mdb.host1" | 3306 | null | "mdbdb"
|
||||
"jdbc:mariadb:loadbalance://127.0.0.1:33,mdb.host/mdbdb" | null | "mariadb:loadbalance://127.0.0.1:33" | "mariadb" | "loadbalance" | null | "127.0.0.1" | 33 | null | "mdbdb"
|
||||
"jdbc:mariadb:loadbalance://127.0.0.1:33/mdbdb" | null | "mariadb:loadbalance://127.0.0.1:33" | "mariadb" | "loadbalance" | null | "127.0.0.1" | 33 | null | "mdbdb"
|
||||
"jdbc:mariadb:loadbalance://[2001:0660:7401:0200:0000:0000:0edf:bdd7]:33,mdb.host/mdbdb" | null | "mariadb:loadbalance://2001:0660:7401:0200:0000:0000:0edf:bdd7:33" | "mariadb" | "loadbalance" | null | "2001:0660:7401:0200:0000:0000:0edf:bdd7" | 33 | null | "mdbdb"
|
||||
"jdbc:mysql:loadbalance://127.0.0.1,127.0.0.1:3306/mdbdb?user=mdbuser&password=PW" | null | "mysql:loadbalance://127.0.0.1:3306" | "mysql" | "loadbalance" | "mdbuser" | "127.0.0.1" | 3306 | null | "mdbdb"
|
||||
"jdbc:mariadb:replication://localhost:33,anotherhost:3306/mdbdb" | null | "mariadb:replication://localhost:33" | "mariadb" | "replication" | null | "localhost" | 33 | null | "mdbdb"
|
||||
|
|
Loading…
Reference in New Issue