On Wed, May 5, 2021 at 1:03 PM Morning Star <[email protected]> wrote:
> private ConnectionFactory searchFactory;
> private AbstractLdapSearchProperties ldapProperties;
> @Autowired
> private CasConfigurationProperties casProperties;
> try{
> val ldap = casProperties.getAuthn().getLdap();
> this.ldapProperties = ldap.get(0);
> this.searchFactory = LdapUtils.newLdaptiveConnectionFactory(ldap.get(0));
> val filter =
> LdapUtils.newLdaptiveSearchFilter(ldapProperties.getSearchFilter(),
> LdapUtils.LDAP_SEARCH_FILTER_DEFAULT_PARAM_NAME,
> Collections.singletonList(upc.getUsername()));
> searchResponse = LdapUtils.executeSearchOperation(searchFactory,
> ldapProperties.getBaseDn(), filter, this.ldapProperties.getPageSize());
> }
> finally
> {
> if(searchFactory != null)
> {
> *searchFactory.close()*;
> log.info(CLASS_NAME + METHOD_NAME + "Connection Factory Closed
> Successfully");
> }
> }
>
Without seeing the entire class it's hard to say, but there are probably
some thread safety issues here. It's likely new connection factories are
getting created before close is getting invoked. I'd recommend initializing
searchFactory as part of the bean's initialization. Otherwise you should
change searchFactory to be a local variable. (It will be fairly inefficient
to create a pooled connection factory for each search operation.)
--Daniel Fisher
--
- Website: https://apereo.github.io/cas
- Gitter Chatroom: https://gitter.im/apereo/cas
- List Guidelines: https://goo.gl/1VRrw7
- Contributions: https://goo.gl/mh7qDG
---
You received this message because you are subscribed to the Google Groups "CAS
Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/a/apereo.org/d/msgid/cas-user/CAFC6YwQO07opF2vFXr2w42mVfaYRmAKkx-yCn7Aw1iq04cocFQ%40mail.gmail.com.