Skip to content

Commit

Permalink
Expose validate-on-borrow
Browse files Browse the repository at this point in the history
Expose the option to validate the connection on borrow as supported by Agroal.

Fix #41616
  • Loading branch information
mkrueger92 authored and Martin Krüger committed Jul 3, 2024
1 parent 16c6ef9 commit bb875c8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,15 @@ public interface DataSourceJdbcRuntimeConfig {
*/
Optional<String> validationQuerySql();

/**
* Forces connection validation prior to acquisition (foreground validation) regardless of the idle status.
* <p>
* Because of the overhead of performing validation on every call, it’s recommended to rely on default idle validation
* instead, and to leave this to `false`.
*/
@WithDefault("false")
boolean validateOnBorrow();

/**
* Disable pooling to prevent reuse of Connections. Use this when an external pool manages the life-cycle
* of Connections.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ public boolean isValid(Connection connection) {
}
});
}
poolConfiguration.validateOnBorrow(dataSourceJdbcRuntimeConfig.validateOnBorrow());
poolConfiguration.reapTimeout(dataSourceJdbcRuntimeConfig.idleRemovalInterval());
if (dataSourceJdbcRuntimeConfig.leakDetectionInterval().isPresent()) {
poolConfiguration.leakTimeout(dataSourceJdbcRuntimeConfig.leakDetectionInterval().get());
Expand Down

0 comments on commit bb875c8

Please sign in to comment.