Improve whitespace handling in oracle jdbc url parser (#12512)

This commit is contained in:
Lauri Tulmin 2024-10-24 20:58:30 +03:00 committed by GitHub
parent e3dc096ac3
commit ca44975c3b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View File

@ -530,10 +530,12 @@ public enum JdbcConnectionUrlParser {
},
ORACLE_AT() {
private final Pattern descriptionPattern = Pattern.compile("@\\s*\\(\\s*description");
@Override
@CanIgnoreReturnValue
DbInfo.Builder doParse(String jdbcUrl, DbInfo.Builder builder) {
if (jdbcUrl.contains("@(description")) {
if (descriptionPattern.matcher(jdbcUrl).find()) {
return ORACLE_AT_DESCRIPTION.doParse(jdbcUrl, builder);
}
String user;
@ -565,7 +567,7 @@ public enum JdbcConnectionUrlParser {
/**
* This parser can locate incorrect data if multiple addresses are defined but not everything is
* defined in the first block. (It would locate data from subsequent address blocks.
* defined in the first block. It would locate data from subsequent address blocks.
*/
ORACLE_AT_DESCRIPTION() {
private final Pattern hostPattern = Pattern.compile("\\(\\s*host\\s*=\\s*([^ )]+)\\s*\\)");

View File

@ -559,7 +559,7 @@ class JdbcConnectionUrlParserTest {
.setPort(666)
.setName("orclsn")
.build(),
arg("jdbc:oracle:thin:@(description = (connect_timeout=90)(retry_count=20)(retry_delay=3) (transport_connect_timeout=3000) (address_list = (load_balance = on) (failover = on) (address = (protocol = tcp)(host = orcl.host1)(port = 1521)) (address = (protocol = tcp)(host = orcl.host2)(port = 1521)) (address = (protocol = tcp)(host = orcl.host3)(port = 1521)) (address = (protocol = tcp)(host = orcl.host4)(port = 1521)) ) (connect_data = (server = dedicated) (service_name = orclsn)))")
arg("jdbc:oracle:thin:@ ( description = (connect_timeout=90)(retry_count=20)(retry_delay=3) (transport_connect_timeout=3000) (address_list = (load_balance = on) (failover = on) (address = (protocol = tcp)(host = orcl.host1 )(port = 1521 )) (address = (protocol = tcp)(host = orcl.host2)(port = 1521)) (address = (protocol = tcp)(host = orcl.host3)(port = 1521)) (address = (protocol = tcp)(host = orcl.host4)(port = 1521)) ) (connect_data = (server = dedicated) (service_name = orclsn)))")
.setShortUrl("oracle:thin://orcl.host1:1521")
.setSystem("oracle")
.setSubtype("thin")