Skip to content

Fix StringIndexOutOfBoundsException parsing JTDS JDBC URLs without a database segment - #12227

Draft
dougqh wants to merge 2 commits into
masterfrom
dougqh/fix-jtds-jdbc-url-port-parsing
Draft

Fix StringIndexOutOfBoundsException parsing JTDS JDBC URLs without a database segment#12227
dougqh wants to merge 2 commits into
masterfrom
dougqh/fix-jtds-jdbc-url-port-parsing

Conversation

@dougqh

@dougqh dougqh commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • JTDS.doParse() in JDBCConnectionUrlParser used dbLoc as the substring end index when parsing the port number, but dbLoc is -1 when the URL has a host:port with no trailing /database and no ;params (e.g. jdbc:jtds:sqlserver://host:1433) — this throws StringIndexOutOfBoundsException from String.substring.
  • Compute the correct end index for the port substring: fall back to paramLoc (when there are ;params but no db) or details.length() (bare host:port) instead of blindly using dbLoc.
  • Found while triaging a production stack trace showing this exception escaping DriverManager.getConnection up through JDBCDecorator.

Test plan

  • Added regression cases to JDBCConnectionUrlParserTest.groovy: jdbc:jtds:sqlserver://dbhostname.com:1433 and jdbc:jtds:sqlserver://dbhostname.com:1433;user=user;password=pw
  • ./gradlew :dd-java-agent:instrumentation:jdbc:test --tests JDBCConnectionUrlParserTest passes
  • Ran /techdebt — no issues found

🤖 Generated with Claude Code

…ase segment

JTDS.doParse() used dbLoc as the end index when extracting the port
number, but dbLoc is -1 when the URL has a host:port with no trailing
/database and no ;params (e.g. jdbc:jtds:sqlserver://host:1433),
causing String.substring to throw.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@dougqh dougqh added type: bug fix Bug fix tag: no release notes Changes to exclude from release notes inst: jdbc JDBC instrumentation tag: ai generated Largely based on code generated by an AI or LLM labels Aug 17, 2026
@datadog-prod-us1-6

datadog-prod-us1-6 Bot commented Aug 17, 2026

Copy link
Copy Markdown

🎯 Code Coverage (details)
Patch Coverage: 0.00%
Overall Coverage: 61.86% (+3.51%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: ee9d285 | Docs | Datadog PR Page | Give us feedback!

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@dd-octo-sts

dd-octo-sts Bot commented Aug 17, 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.96 s 13.91 s [-0.4%; +1.1%] (no difference)
startup:insecure-bank:tracing:Agent 12.89 s 12.96 s [-1.4%; +0.3%] (no difference)
startup:petclinic:appsec:Agent 17.41 s 17.12 s [+0.7%; +2.6%] (maybe worse)
startup:petclinic:iast:Agent 16.69 s 17.44 s [-8.4%; -0.2%] (maybe better)
startup:petclinic:profiling:Agent 17.33 s 17.37 s [-1.5%; +1.1%] (no difference)
startup:petclinic:sca:Agent 17.48 s 17.23 s [+0.6%; +2.3%] (maybe worse)
startup:petclinic:tracing:Agent 16.15 s 16.59 s [-6.8%; +1.5%] (no difference)

Commit: ee9d2850 · 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.

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 tag: no release notes Changes to exclude from release notes type: bug fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant