From b0211911b51cc4bc0a13c3f5f49d15d3fe5e1bcf Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Tue, 7 Apr 2015 08:39:59 +0200 Subject: [PATCH] DATACMNS-677 - AnnotationBasedPersistentProperty now caches absence of annotations on accessor-only properties. AnnotationBasedPersistentProperty now also caches the absence of properties that are expressed through accessors only. Previously the absence of a field caused us to skip the registration of the absence in the cache. --- .../AnnotationBasedPersistentProperty.java | 7 +++--- ...ationBasedPersistentPropertyUnitTests.java | 24 +++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/springframework/data/mapping/model/AnnotationBasedPersistentProperty.java b/src/main/java/org/springframework/data/mapping/model/AnnotationBasedPersistentProperty.java index 36c1f6649..8820f1cda 100644 --- a/src/main/java/org/springframework/data/mapping/model/AnnotationBasedPersistentProperty.java +++ b/src/main/java/org/springframework/data/mapping/model/AnnotationBasedPersistentProperty.java @@ -201,8 +201,9 @@ public abstract class AnnotationBasedPersistentProperty

, ?> field = (Map, ?>) ReflectionTestUtils.getField(property, "annotationCache"); + + assertThat(field.containsKey(MyAnnotation.class), is(true)); + assertThat(field.get(MyAnnotation.class), is(nullValue())); + } + @SuppressWarnings("unchecked") private Map, Annotation> getAnnotationCache(SamplePersistentProperty property) { return (Map, Annotation>) ReflectionTestUtils.getField(property, "annotationCache"); @@ -250,6 +267,13 @@ public class AnnotationBasedPersistentPropertyUnitTests