Quick fix for threading issue. Should maybe look into synchronizing this method instead.

This commit is contained in:
Joel Leitch 2011-06-07 01:28:30 +00:00
parent 9ad3358728
commit aa89773008

View File

@ -159,12 +159,13 @@ public final class FieldAttributes {
public Collection<Annotation> getAnnotations() { public Collection<Annotation> getAnnotations() {
if (annotations == null) { if (annotations == null) {
Pair<Class<?>, String> key = new Pair<Class<?>, String>(declaringClazz, name); Pair<Class<?>, String> key = new Pair<Class<?>, String>(declaringClazz, name);
annotations = ANNOTATION_CACHE.getElement(key); Collection<Annotation> cachedValue = ANNOTATION_CACHE.getElement(key);
if (annotations == null) { if (cachedValue == null) {
annotations = Collections.unmodifiableCollection( cachedValue = Collections.unmodifiableCollection(
Arrays.asList(field.getAnnotations())); Arrays.asList(field.getAnnotations()));
ANNOTATION_CACHE.addElement(key, annotations); ANNOTATION_CACHE.addElement(key, cachedValue);
} }
annotations = cachedValue;
} }
return annotations; return annotations;
} }