Skip to content

Fix DB2 JDBC URL parsing failure when :// is only in a property value (quick fix) - #12803

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 5 commits into
masterfrom
dougqh/jdbc-url-parser-db2
Oct 13, 2026
Merged

gh-worker-dd-mergequeue-cf854d[bot] merged 5 commits into
masterfrom
dougqh/jdbc-url-parser-db2

Conversation

@dougqh

@dougqh dougqh commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

What Does This Do

Stops JDBCConnectionUrlParser from throwing StringIndexOutOfBoundsException on DB2/AS400 URLs that have no // after the type and whose only :// is inside a ; property value, for example:

  • jdbc:as400:host;ssltruststore=file://x
  • jdbc:as400:host;libraries=a;secure=true;keystore=file:///x
  • jdbc:db2:mydb;x=http://y

MODIFIED_URL_LIKE took that :// as the host delimiter. The type then wasn't db2/as400, so the code went down the generic ; branch and cut urlPart1 at the earlier ;. That left it shorter than hostIndex + 3, and urlPart1.substring(hostIndex + 3) threw. Now, when the first ; comes before ://, the parser returns the builder unchanged. That's the same DBInfo the exception fallback in parse already produced (type and default port 50000, no host), just without the exception. URLs that parsed before still parse the same way.

Motivation

Error Tracking issue https://app.datadoghq.com/error-tracking/issue/ab130d54-aab1-11f0-80ae-da7ad0900002 ("Error parsing URL", ~3.3k errors/day, still alerting on 1.66):

java.lang.StringIndexOutOfBoundsException
  at java.lang.String.substring
  at JDBCConnectionUrlParser$2.doParse(JDBCConnectionUrlParser.java:109)   // MODIFIED_URL_LIKE
  at JDBCConnectionUrlParser$9.doParse(JDBCConnectionUrlParser.java:344)   // DB2

#11550 (1.64.0) fixed one cause, the lastIndexOf(':') landing inside ://. But the monitor kept firing on 1.66. I ran a wide set of DB2/AS400 URL forms through DB2.doParse on current code, and the form above was the only one that still threw.

Additional Notes

  • Stacked on Fix Oracle and jTDS JDBC URL parsing failures (quick fix) #12780, which reworks the same file.
  • Added regression rows to JDBCConnectionUrlParserDB2Test. The test calls DB2.doParse directly because extractDBInfo swallows exceptions. All 4 rows fail without the fix and pass with it.
  • Ran :dd-java-agent:agent-bootstrap:test --tests '*JDBCConnectionUrlParser*', :dd-java-agent:instrumentation:jdbc:test --tests JDBCConnectionUrlParserTest, spotlessJavaCheck and forbiddenApisMain. All passed.

🤖 Generated with Claude Code

@dougqh dougqh added type: bug fix Bug fix inst: jdbc JDBC instrumentation tag: ai generated Largely based on code generated by an AI or LLM labels Oct 8, 2026
@dougqh
dougqh marked this pull request as ready for review October 8, 2026 19:34
@dougqh
dougqh requested a review from a team as a code owner October 8, 2026 19:34
@dougqh
dougqh requested review from sarahchen6 and removed request for a team October 8, 2026 19:34
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-08T19:37:58.288416Z da7f3d0 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: da7f3d0fff

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@datadog-official

This comment has been minimized.

@dd-octo-sts

dd-octo-sts Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

🟢 Java Benchmark SLOs — All performance SLOs passed

Suite Status
Startup 🟢 pass

SLO thresholds are defined here based on automatically generated metrics. A warning is raised when results are within 5% of the threshold.

PR vs. master results
Scenario Candidate master Δ (95% CI of mean)
startup:insecure-bank:iast:Agent 13.92 s 13.85 s [-0.2%; +1.2%] (no difference)
startup:insecure-bank:tracing:Agent 12.85 s 12.97 s [-1.6%; -0.2%] (maybe better)
startup:petclinic:appsec:Agent 17.07 s 17.02 s [-0.5%; +1.1%] (no difference)
startup:petclinic:iast:Agent 16.36 s 16.89 s [-7.3%; +1.0%] (no difference)
startup:petclinic:profiling:Agent 16.44 s 16.80 s [-3.2%; -1.2%] (significantly better)
startup:petclinic:sca:Agent 17.02 s 16.97 s [-0.6%; +1.1%] (no difference)
startup:petclinic:tracing:Agent 16.10 s 15.70 s [-1.8%; +6.8%] (no difference)

Commit: 5012fa08 · CI Pipeline · Benchmarking Platform UI


Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion.

@datadog-official datadog-official Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bits Code Review: FAIL

The guard avoids the exception but drops recognized URL properties that the previous fallback preserved, including the user consumed by JDBC span decoration.

Open Bits AI session

🤖 Bits Code Review · Commit da7f3d0 · @DataDog review to ask questions

@sarahchen6 sarahchen6 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The codex/dd review looks worth addressing, but otherwise LGTM

Base automatically changed from dougqh/jdbc-url-parser-oracle-jtds to master October 9, 2026 21:02
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot requested a review from a team as a code owner October 9, 2026 21:02
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot requested review from ValentinZakharov and removed request for a team October 9, 2026 21:02

@datadog-official datadog-official Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bits Code Review: FAIL

Previously accepted ports such as +1444 now fall back to vendor defaults, producing incorrect JDBC connection metadata. The inline replacement preserves that compatibility without changing the integer utility's digits-only contract.

Open Bits AI session

🤖 Bits Code Review · Commit f39cdd7

dougqh and others added 2 commits October 9, 2026 17:52
A DB2/AS400 URL without // after the type (e.g. jdbc:as400:host;keystore=file:///x)
whose only :// sits inside a ';' property value made MODIFIED_URL_LIKE take the
'://' as the host delimiter while cutting urlPart1 at the earlier ';', so
urlPart1.substring(hostIndex + 3) threw StringIndexOutOfBoundsException.
Return the builder unchanged in that case, which is the same DBInfo the
exception fallback produced, minus the exception.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The early return skipped splitQuery/populateStandardProperties, so properties
such as user or schema were lost. The old parser applied them before throwing
and parse() returned that builder from its catch block, so populate them
before returning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dougqh
dougqh force-pushed the dougqh/jdbc-url-parser-db2 branch from f39cdd7 to 07713f9 Compare October 9, 2026 22:02
@dougqh
dougqh enabled auto-merge October 10, 2026 01:43
@dougqh
dougqh added this pull request to the merge queue Oct 13, 2026
@dd-octo-sts

dd-octo-sts Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-10-13 13:08:57 UTC ℹ️ Start processing command /merge


2026-10-13 13:09:02 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 1h (p90).


2026-10-13 14:09:11 UTC ℹ️ MergeQueue: This merge request was merged

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 13, 2026
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit 54ea5df into master Oct 13, 2026
610 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the dougqh/jdbc-url-parser-db2 branch October 13, 2026 14:09
@github-actions github-actions Bot added this to the 1.68.0 milestone Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

inst: jdbc JDBC instrumentation tag: ai generated Largely based on code generated by an AI or LLM type: bug fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants