Skip to content

Fix JDBC timeout handling and pooled state restoration - #561

Merged
garydgregory merged 9 commits into
apache:masterfrom
garydgregory:fix-jdbc-timeout-handling
Nov 23, 2026
Merged

garydgregory merged 9 commits into
apache:masterfrom
garydgregory:fix-jdbc-timeout-handling

Conversation

@garydgregory

@garydgregory garydgregory commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Fix JDBC timeout handling and pooled state restoration

Centralize Duration conversion to JDBC seconds, preserving positive sub-second timeouts, capping oversized values, and retaining negative values for driver validation. Close statements when timeout setup fails.

Restore original query timeouts when returning pooled prepared and callable statements. Discard statements if restoration fails and clear saved timeout state when replacing delegates.

Apply configured login timeouts to physical connection attempts with provider-scoped coordination, bounded waits, and failure cleanup. Restore provider settings afterwards and preserve live configuration across deserialization.

Preserve DriverAdapterCPDS eviction durations through JNDI References, preferring Duration properties and accepting legacy long millisecond values.

Undeprecate DelegatingConnection.isValid(int) while preserving existing overload dispatch.

Update Javadoc and release notes. Add regression coverage for timeout boundaries, statement reuse, failure paths, JNDI, serialization, and concurrent provider access.

Assisted-By: OpenAI Codex

  • Read the contribution guidelines for this project.
  • Read the ASF Generative Tooling Guidance if you use Artificial Intelligence (AI).
  • I used AI to create any part of, or all of, this pull request: GPT-6 Astra Extra High.
  • Run a successful build using the default Maven goal with mvn; that's mvn on the command line by itself.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied. This may not always be possible, but it is a best practice.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body. Note that a maintainer may squash commits during the merge process.

Centralize Duration conversion to JDBC seconds, preserving positive
sub-second timeouts, capping oversized values, and retaining negative
values for driver validation. Close statements when timeout setup fails.

Restore original query timeouts when returning pooled prepared and
callable statements. Discard statements if restoration fails and clear
saved timeout state when replacing delegates.

Apply configured login timeouts to physical connection attempts with
provider-scoped coordination, bounded waits, and failure cleanup.
Restore
provider settings afterwards and preserve live configuration across
deserialization.

Preserve DriverAdapterCPDS eviction durations through JNDI References,
preferring Duration properties and accepting legacy long millisecond
values.

Undeprecate DelegatingConnection.isValid(int) while preserving existing
overload dispatch.

Update Javadoc and release notes. Add regression coverage for timeout
boundaries, statement reuse, failure paths, JNDI, serialization, and
concurrent provider access.
AbstractConnectionFactory.loginTimeoutSupplier final
AbstractConnectionFactory.maxConnDuration final
implements javax.sql.CommonDataSource.setLoginTimeout(int)
Work around Duration.parse() losing the sign of negative-zero seconds
components when restoring DriverAdapterCPDS JNDI References. Normalize
the seconds component before parsing and compensate for the adjustment,
respecting the duration's leading sign.

Preserve existing ISO-8601 output and extreme duration values. Add
regression coverage for mixed signs, minute/hour boundaries, malformed
input, and legacy-property precedence. Update release notes.
Share live login timeout configuration only when deserialization reuses
a registered data source. Otherwise, retain the serialized local
setting,
including the distinction between an unset timeout and explicit zero.

Add regression coverage for repeated serialization, timeout boundaries,
direct and JNDI providers, and registered sources before pool
initialization. Extract common test setup and serialization helpers.

Complete Javadoc for timeout methods and tests. Add @SInCE 2.15.0 to new
public and protected API methods, and update release notes.
Allow closePool(null) to close a pool using default credentials when
its configured user name is also null. Preserve matching behavior
for non-null user names.

Document null matching and add regression coverage for matching,
mismatching, and null user names, including idle connection cleanup.
Use Objects.equals for both password comparisons in
InstanceKeyDataSource.getConnection. Accept matching null passwords
during retries after a password change.

Add regression coverage for both pool types, including changes to
and from null and rejection of incorrect passwords. Document
null-password equality.
@garydgregory
garydgregory merged commit bfd20dd into apache:master Nov 23, 2026
10 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant