Skip to content

Commit

Permalink
Improve whitespace handling in oracle jdbc url parser (#12512)
Browse files Browse the repository at this point in the history
  • Loading branch information
laurit authored Oct 24, 2024
1 parent e3dc096 commit ca44975
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,12 @@ DbInfo.Builder doParse(String jdbcUrl, DbInfo.Builder builder) {
},

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;
Expand Down Expand Up @@ -565,7 +567,7 @@ DbInfo.Builder doParse(String jdbcUrl, DbInfo.Builder builder) {

/**
* 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*\\)");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
.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")
Expand Down

0 comments on commit ca44975

Please sign in to comment.