@Bean
    @RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
    public ListFactoryBean pooledLdapConnectionFactoryHealthIndicatorListFactoryBean() {
        val list = new ListFactoryBean() {
            @Override
            protected void destroyInstance(final List list) {
                Objects.requireNonNull(list).forEach(connectionFactory ->
                    ((ConnectionFactory) connectionFactory).close()
                );
            }
        };
        list.setSourceList(new ArrayList<>());
        return list;
    }
This is {@link CasLdapMonitorAutoConfiguration}.

@author Misagh Moayyed
@since 5.0.0
support/cas-server-support-ldap-monitor/src/main/java/org/apereo/cas/config/CasLdapMonitorAutoConfiguration.java