This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.
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?