Skip to content

Commit

Permalink
Applying comment
Browse files Browse the repository at this point in the history
  • Loading branch information
torcato committed Jun 24, 2024
1 parent a992994 commit 55fa740
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/

package raw.client.sql
import com.google.common.cache.{CacheBuilder, CacheLoader, LoadingCache}
import com.google.common.cache.{CacheBuilder, CacheLoader, LoadingCache, RemovalNotification}
import com.typesafe.scalalogging.StrictLogging
import com.zaxxer.hikari.{HikariConfig, HikariDataSource}
import raw.creds.api.CredentialsService
Expand Down Expand Up @@ -68,6 +68,10 @@ class SqlConnectionPool(credentialsService: CredentialsService)(implicit setting
.newBuilder()
.maximumSize(connectionCacheSize)
.expireAfterAccess(connectionCachePeriod)
.removalListener((notification: RemovalNotification[AuthenticatedUser, HikariDataSource]) => {
logger.info(s"Shutting down SQL connection pool for database ${notification.getValue.getJdbcUrl}")
RawUtils.withSuppressNonFatalException(notification.getValue.close())
})
.build(dbCacheLoader)

@throws[SQLException]
Expand Down

0 comments on commit 55fa740

Please sign in to comment.