In a spring cloud function usage, you don't want your database connection to keep existing in the database. Once the spring cloud function finishes its process, is the following way to close the function appropriate?
HikariDataSource ds = (HikariDataSource) applicationContext.getBean(HikariDataSource.class);
if (ds != null) {
ds.close();
}
How do we validate if the spring cloud function inherently closes the connection even if we don't do the implementation above? I saw the log below indicating that the connection pool is closed, but also that the database keeps growing its connections, indicating that connections are not properly closed. How do we make sure the connections are closed after spring cloud function implementation is finished?
INFO 22336 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
INFO 22336 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.