From 769793496719ddc8408a2ec447d06542f571b13b Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Fri, 18 Feb 2011 10:34:46 -0800 Subject: [PATCH] fixed a possible race condition (INFRADNA-65) Originally-Committed-As: a9efb3dac2363331e577b08cbd876f890df303f3 --- core/src/main/java/hudson/security/LDAPSecurityRealm.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/hudson/security/LDAPSecurityRealm.java b/core/src/main/java/hudson/security/LDAPSecurityRealm.java index 87ae5ae..147d78b 100644 --- a/core/src/main/java/hudson/security/LDAPSecurityRealm.java +++ b/core/src/main/java/hudson/security/LDAPSecurityRealm.java @@ -436,9 +436,11 @@ public class LDAPSecurityRealm extends AbstractPasswordBasedSecurityRealm { // intern attributes Attributes v = ldapUser.getAttributes(); if (v instanceof BasicAttributes) {// BasicAttributes.equals is what makes the interning possible - Attributes vv = (Attributes)attributesCache.get(v); - if (vv==null) attributesCache.put(v,vv=v); - user.setAttributes(vv); + synchronized (attributesCache) { + Attributes vv = (Attributes)attributesCache.get(v); + if (vv==null) attributesCache.put(v,vv=v); + user.setAttributes(vv); + } } GrantedAuthority[] extraAuthorities = authoritiesPopulator.getGrantedAuthorities(ldapUser);