fixed a possible race condition (INFRADNA-65)

Originally-Committed-As: a9efb3dac2363331e577b08cbd876f890df303f3
This commit is contained in:
Kohsuke Kawaguchi 2011-02-18 10:34:46 -08:00
parent baec8a9e47
commit 7697934967

View file

@ -436,9 +436,11 @@ public class LDAPSecurityRealm extends AbstractPasswordBasedSecurityRealm {
// intern attributes // intern attributes
Attributes v = ldapUser.getAttributes(); Attributes v = ldapUser.getAttributes();
if (v instanceof BasicAttributes) {// BasicAttributes.equals is what makes the interning possible if (v instanceof BasicAttributes) {// BasicAttributes.equals is what makes the interning possible
Attributes vv = (Attributes)attributesCache.get(v); synchronized (attributesCache) {
if (vv==null) attributesCache.put(v,vv=v); Attributes vv = (Attributes)attributesCache.get(v);
user.setAttributes(vv); if (vv==null) attributesCache.put(v,vv=v);
user.setAttributes(vv);
}
} }
GrantedAuthority[] extraAuthorities = authoritiesPopulator.getGrantedAuthorities(ldapUser); GrantedAuthority[] extraAuthorities = authoritiesPopulator.getGrantedAuthorities(ldapUser);