From 8a7901f292a278249bc0e7596f2e9d506f95588a Mon Sep 17 00:00:00 2001 From: Florian Rampp Date: Wed, 7 Oct 2015 15:18:47 +0200 Subject: [PATCH] do not fail if setLoginTimeout on delegate data source is not supported Some `DataSource` implementations (like [`BasicDataSource`](https://commons.apache.org/proper/commons-dbcp/api-1.4/org/apache/commons/dbcp/BasicDataSource.html) or [`DriverManagerDataSource`](https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/jdbc/datasource/DriverManagerDataSource.html) do not support setting a login timeout. `UnsupportedOperationException` is thrown in these cases. When a delegate `dataSource` is set for the HikariCP, it tries to invoke this method on the delegate. Only log a warning in this case instead of failing to initialize the HikariCP in this case. This is amongst others relevant for using HikariCP in Grails, which creates instances of `org.springframework.jdbc.datasource.DriverManagerDataSource` (at least in version 2.2.4). --- src/main/java/com/zaxxer/hikari/pool/PoolBase.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/zaxxer/hikari/pool/PoolBase.java b/src/main/java/com/zaxxer/hikari/pool/PoolBase.java index d00f747c..5b6d6175 100644 --- a/src/main/java/com/zaxxer/hikari/pool/PoolBase.java +++ b/src/main/java/com/zaxxer/hikari/pool/PoolBase.java @@ -528,6 +528,9 @@ abstract class PoolBase catch (SQLException e) { LOGGER.warn("{} - Unable to set DataSource login timeout", poolName, e); } + catch (UnsupportedOperationException e) { + LOGGER.warn("{} - Unable to set DataSource login timeout", poolName, e); + } } }