garydgregory commented on PR #548:
URL: https://github.com/apache/commons-dbcp/pull/548#issuecomment-7084101963
@AryanRG
Thank you for your PR.
The original PR fixes the bug correctly. Commit b7f6ec70 provides a more
complete contract and much stronger regression protection. I verified that the
executable `validate(String, Duration)` implementation is identical in both
versions.
The reasons to prefer our commit are:
1. It corrects a misleading API promise.
The PR says zero or negative durations mean “no timeout.” For a cached
validation statement, they actually leave its existing timeout unchanged. For
example, validating with five seconds and then zero retains five seconds. Our
commit documents this distinction explicitly. [Updated
Javadoc](/Users/garygregory/git/commons/commons-dbcp/src/main/java/org/apache/commons/dbcp2/PoolableConnection.java:395)
2. It proves the exact conversion in both JDBC paths.
The PR’s query regression only checks that validation fails with a
timeout. Its fixture would also fail for an incorrectly supplied timeout of
two, three, or four seconds. Our tests verify that JDBC receives exactly one
second and that the timeout is set before query execution. The original
no-query test already checks one second correctly. [Query conversion
tests](/Users/garygregory/git/commons/commons-dbcp/src/test/java/org/apache/commons/dbcp2/TestPoolableConnection.java:408)
3. It covers the additional overflow behavior.
The PR already introduces capping at `Integer.MAX_VALUE`, but neither
documents nor tests that policy. Our commit covers values immediately below,
at, and above the limit, values that would previously wrap to zero, and the
largest supported duration. It also tests nanosecond precision, fractional
seconds, zero, and negative durations. [Boundary
cases](/Users/garygregory/git/commons/commons-dbcp/src/test/java/org/apache/commons/dbcp2/TestPoolableConnection.java:81)
4. It tests repeated validation and failure handling.
The PR’s new tests exercise individual validations. Our additions verify
cached-statement reuse, timeout updates, retention of prior timeouts, and
changing SQL. They also check null and empty SQL, false validation results,
exception propagation, empty result sets, and fast-fail enabled and disabled
after a fatal exception. [Cached-statement
tests](/Users/garygregory/git/commons/commons-dbcp/src/test/java/org/apache/commons/dbcp2/TestPoolableConnection.java:426),
[fast-fail
tests](/Users/garygregory/git/commons/commons-dbcp/src/test/java/org/apache/commons/dbcp2/TestPoolableConnection.java:280)
5. It completes the documentation and release record.
Our commit explains fractional-second truncation and overflow capping,
corrects the null/empty SQL documentation and malformed link, and includes the
DBCP-600 changelog entry with contributor credit.
The additional tests cover every line and branch of the changed method and
rejected all seven deliberately broken variants we checked. The full Maven
build also passed.
I would describe the original contribution as **a sound fix that needed
documentation corrections and broader tests**, rather than an incorrect
implementation.
Closing; you are credited in `changes.xml`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]