Can someone help me?

On Thursday, May 6, 2021 at 10:23:42 PM UTC+5:30 Morning Star wrote:

> Hi Daniel,
>
> Thanks for your response.
>
> Please find the attached source code.
>
>
> On Thursday, May 6, 2021 at 12:44:22 AM UTC+5:30 dfisher wrote:
>
>> 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/6572d325-5f6d-4776-9ba9-838bd81a89fen%40apereo.org.

Reply via email to