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.
This commit is contained in:
@@ -203,6 +203,23 @@ public class AnnotationBasedPersistentPropertyUnitTests<P extends AnnotationBase
|
||||
getProperty(TypeWithCustomAnnotationsOnBothFieldAndAccessor.class, "field");
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACMNS-677
|
||||
*/
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void cachesNonPresenceOfAnnotationOnField() {
|
||||
|
||||
SamplePersistentProperty property = getProperty(Sample.class, "getterWithoutField");
|
||||
|
||||
assertThat(property.findAnnotation(MyAnnotation.class), is(nullValue()));
|
||||
|
||||
Map<Class<?>, ?> field = (Map<Class<?>, ?>) ReflectionTestUtils.getField(property, "annotationCache");
|
||||
|
||||
assertThat(field.containsKey(MyAnnotation.class), is(true));
|
||||
assertThat(field.get(MyAnnotation.class), is(nullValue()));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Map<Class<? extends Annotation>, Annotation> getAnnotationCache(SamplePersistentProperty property) {
|
||||
return (Map<Class<? extends Annotation>, Annotation>) ReflectionTestUtils.getField(property, "annotationCache");
|
||||
@@ -250,6 +267,13 @@ public class AnnotationBasedPersistentPropertyUnitTests<P extends AnnotationBase
|
||||
public void setDoubleMapping(String doubleMapping) {
|
||||
this.doubleMapping = doubleMapping;
|
||||
}
|
||||
|
||||
@AccessType(Type.PROPERTY)
|
||||
public Object getGetterWithoutField() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setGetterWithoutField(Object object) {}
|
||||
}
|
||||
|
||||
static class InvalidSample {
|
||||
|
||||
Reference in New Issue
Block a user