Avoid NPE in PropertyMappingContextCustomizer

See gh-9914
This commit is contained in:
Dennis Kieselhorst 2017-07-31 10:26:05 +02:00 committed by Andy Wilkinson
parent 3cc22ecffb
commit e7a6b8c260

View File

@ -79,12 +79,15 @@ class PropertyMappingContextCustomizer implements ContextCustomizer {
Set<Class<?>> components = new LinkedHashSet<Class<?>>();
Set<Class<?>> propertyMappings = new LinkedHashSet<Class<?>>();
while (beanClass != null) {
for (Annotation annotation : AnnotationUtils.getAnnotations(beanClass)) {
if (isAnnotated(annotation, Component.class)) {
components.add(annotation.annotationType());
}
if (isAnnotated(annotation, PropertyMapping.class)) {
propertyMappings.add(annotation.annotationType());
Annotation[] annotations = AnnotationUtils.getAnnotations(beanClass);
if (annotations != null) {
for (Annotation annotation : annotations) {
if (isAnnotated(annotation, Component.class)) {
components.add(annotation.annotationType());
}
if (isAnnotated(annotation, PropertyMapping.class)) {
propertyMappings.add(annotation.annotationType());
}
}
}
beanClass = beanClass.getSuperclass();