Index: common/src/java/org/apache/ldap/common/schema/CachingNormalizer.java =================================================================== --- common/src/java/org/apache/ldap/common/schema/CachingNormalizer.java (revision 280676) +++ common/src/java/org/apache/ldap/common/schema/CachingNormalizer.java (working copy) @@ -75,13 +75,29 @@ */ public Object normalize( Object value ) throws NamingException { - if ( cache.containsKey( value ) ) + Object normalized; + + /* + * Use of R/W lock is more appropriate here. Consider using JSR 166 + * backport ConcurrentHashMap or ReentrantReadWriteLock. Get read lock + * for this block. + */ + synchronized ( cache ) { - return cache.get( value ) ; + normalized = cache.get( value ) ; + if (null != normalized || cache.containsKey( value )) + { + return normalized; + } } + + normalized = normalizer.normalize( value ) ; + // Get write lock for this block. + synchronized ( cache ) + { + cache.put( value, normalized ) ; + } - Object normalized = normalizer.normalize( value ) ; - cache.put( value, normalized ) ; return normalized ; } }