3535import org .springframework .util .ConcurrentReferenceHashMap ;
3636import org .springframework .util .ObjectUtils ;
3737import org .springframework .util .ReflectionUtils ;
38+ import org .springframework .util .StringUtils ;
3839
3940/**
4041 * General utility methods for working with annotations, handling bridge methods
@@ -654,6 +655,9 @@ public static Object getValue(Annotation annotation) {
654655 * @see #getValue(Annotation)
655656 */
656657 public static Object getValue (Annotation annotation , String attributeName ) {
658+ if (annotation == null || !StringUtils .hasLength (attributeName )) {
659+ return null ;
660+ }
657661 try {
658662 Method method = annotation .annotationType ().getDeclaredMethod (attributeName );
659663 ReflectionUtils .makeAccessible (method );
@@ -683,6 +687,9 @@ public static Object getDefaultValue(Annotation annotation) {
683687 * @see #getDefaultValue(Class, String)
684688 */
685689 public static Object getDefaultValue (Annotation annotation , String attributeName ) {
690+ if (annotation == null ) {
691+ return null ;
692+ }
686693 return getDefaultValue (annotation .annotationType (), attributeName );
687694 }
688695
@@ -706,6 +713,9 @@ public static Object getDefaultValue(Class<? extends Annotation> annotationType)
706713 * @see #getDefaultValue(Annotation, String)
707714 */
708715 public static Object getDefaultValue (Class <? extends Annotation > annotationType , String attributeName ) {
716+ if (annotationType == null || !StringUtils .hasLength (attributeName )) {
717+ return null ;
718+ }
709719 try {
710720 return annotationType .getDeclaredMethod (attributeName ).getDefaultValue ();
711721 }
0 commit comments