Skip to content

Commit ca44975

Browse files
authored
Improve whitespace handling in oracle jdbc url parser (#12512)
1 parent e3dc096 commit ca44975

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcConnectionUrlParser.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,10 +530,12 @@ DbInfo.Builder doParse(String jdbcUrl, DbInfo.Builder builder) {
530530
},
531531

532532
ORACLE_AT() {
533+
private final Pattern descriptionPattern = Pattern.compile("@\\s*\\(\\s*description");
534+
533535
@Override
534536
@CanIgnoreReturnValue
535537
DbInfo.Builder doParse(String jdbcUrl, DbInfo.Builder builder) {
536-
if (jdbcUrl.contains("@(description")) {
538+
if (descriptionPattern.matcher(jdbcUrl).find()) {
537539
return ORACLE_AT_DESCRIPTION.doParse(jdbcUrl, builder);
538540
}
539541
String user;
@@ -565,7 +567,7 @@ DbInfo.Builder doParse(String jdbcUrl, DbInfo.Builder builder) {
565567

566568
/**
567569
* This parser can locate incorrect data if multiple addresses are defined but not everything is
568-
* defined in the first block. (It would locate data from subsequent address blocks.
570+
* defined in the first block. It would locate data from subsequent address blocks.
569571
*/
570572
ORACLE_AT_DESCRIPTION() {
571573
private final Pattern hostPattern = Pattern.compile("\\(\\s*host\\s*=\\s*([^ )]+)\\s*\\)");

instrumentation/jdbc/library/src/test/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcConnectionUrlParserTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
559559
.setPort(666)
560560
.setName("orclsn")
561561
.build(),
562-
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)))")
562+
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)))")
563563
.setShortUrl("oracle:thin://orcl.host1:1521")
564564
.setSystem("oracle")
565565
.setSubtype("thin")

0 commit comments

Comments
 (0)