in app/src/main/java/com/amazon/aws/partners/saasfactory/pgrls/configuration/TenantLogoutHandler.java [46:59]
public void onLogoutSuccess(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, ServletException {
UUID tenantId = ((Tenant) authentication.getPrincipal()).getId();
LOGGER.info("Tenant logout: removing database connection pool for tenant {}", tenantId);
// Can't just call databaseConnectionPools.dataSource() because we just logged out the security context
// principal and we'll get a null pointer when it tries to resolve the pool from it's target map.
DataSource connectionPool = (DataSource) databaseConnectionPools.getDataSourceTargets().get(tenantId);
// Explicitly close down the connection pool
if (connectionPool != null) {
((HikariDataSource) connectionPool).close();
}
// And remove it from the list of targets
databaseConnectionPools.getDataSourceTargets().remove(tenantId);
super.onLogoutSuccess(httpServletRequest, httpServletResponse, authentication);
}