diff --git a/gson/src/main/java/com/google/gson/FieldAttributes.java b/gson/src/main/java/com/google/gson/FieldAttributes.java index b69ebf92..0aa47511 100644 --- a/gson/src/main/java/com/google/gson/FieldAttributes.java +++ b/gson/src/main/java/com/google/gson/FieldAttributes.java @@ -159,12 +159,13 @@ public final class FieldAttributes { public Collection getAnnotations() { if (annotations == null) { Pair, String> key = new Pair, String>(declaringClazz, name); - annotations = ANNOTATION_CACHE.getElement(key); - if (annotations == null) { - annotations = Collections.unmodifiableCollection( + Collection cachedValue = ANNOTATION_CACHE.getElement(key); + if (cachedValue == null) { + cachedValue = Collections.unmodifiableCollection( Arrays.asList(field.getAnnotations())); - ANNOTATION_CACHE.addElement(key, annotations); + ANNOTATION_CACHE.addElement(key, cachedValue); } + annotations = cachedValue; } return annotations; }