Welcome to the new Spring.io forums!
If this is your first visit, be sure to check out the
by clicking the link above, and for security reasons, use the
forgot password link to reset your password..
You may have to register before you can post: click the register
link above to proceed. To start viewing messages, select the forum that you want to visit
from the selection below.
Yes, the LdapTemplate class and its collaborators don't hold any state and should be fully thread safe.
The exeption would be DistinguishedName and its components; modifying the same DistinguishedName in different threads would have undefined behavior, but then again I can't think of any case where that would be desired.
While I know this thread is old, I hope that I might get a clarification on something.
While the LdapTemplate, LdapContextSource and InitialLdapContext may be thread safe, the javax.naming.InitialContext and javax.naming.InitialDirContext that these classes wrap are not thread safe, so multiple threads accessing a single context must be synchronized.
So, is LdapTemplate etc, synchronized (looking at the source, they don't appear to be) or is there some other synchronization mechanism at play here?
Lastly, in order to obtain multiple contexts, and given that LDAP contexts are pooled, Would it maybe be more performant to define the LDAP context etc as prototype rather than singleton, so each thread obtains it's own context?