Avoid NPE in AnnotationsPropertySource if getAnnotations returns null

Closes gh-9914
pull/9989/merge
Andy Wilkinson 7 years ago
parent 25d0cc167e
commit 7967c64d65

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2016 the original author or authors. * Copyright 2012-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -85,12 +85,15 @@ public class AnnotationsPropertySource extends EnumerablePropertySource<Class<?>
private List<Annotation> getMergedAnnotations(Class<?> root, Class<?> source) { private List<Annotation> getMergedAnnotations(Class<?> root, Class<?> source) {
List<Annotation> mergedAnnotations = new ArrayList<Annotation>(); List<Annotation> mergedAnnotations = new ArrayList<Annotation>();
for (Annotation annotation : AnnotationUtils.getAnnotations(source)) { Annotation[] annotations = AnnotationUtils.getAnnotations(source);
if (annotations != null) {
for (Annotation annotation : annotations) {
if (!AnnotationUtils.isInJavaLangAnnotationPackage(annotation)) { if (!AnnotationUtils.isInJavaLangAnnotationPackage(annotation)) {
mergedAnnotations mergedAnnotations
.add(findMergedAnnotation(root, annotation.annotationType())); .add(findMergedAnnotation(root, annotation.annotationType()));
} }
} }
}
return mergedAnnotations; return mergedAnnotations;
} }

Loading…
Cancel
Save