@@ -533,6 +533,9 @@ private static <A extends Annotation> A findAnnotation(
533
533
@ Nullable
534
534
public static <A extends Annotation > A findAnnotation (Method method , Class <A > annotationType ) {
535
535
Assert .notNull (method , "Method must not be null" );
536
+ if (annotationType == null ) {
537
+ return null ;
538
+ }
536
539
537
540
AnnotationCacheKey cacheKey = new AnnotationCacheKey (method , annotationType );
538
541
A result = (A ) findAnnotationCache .get (cacheKey );
@@ -655,6 +658,10 @@ public static <A extends Annotation> A findAnnotation(Class<?> clazz, Class<A> a
655
658
@ Nullable
656
659
private static <A extends Annotation > A findAnnotation (Class <?> clazz , Class <A > annotationType , boolean synthesize ) {
657
660
Assert .notNull (clazz , "Class must not be null" );
661
+ if (annotationType == null ) {
662
+ return null ;
663
+ }
664
+
658
665
AnnotationCacheKey cacheKey = new AnnotationCacheKey (clazz , annotationType );
659
666
A result = (A ) findAnnotationCache .get (cacheKey );
660
667
if (result == null ) {
@@ -1310,7 +1317,7 @@ public static Object getValue(Annotation annotation) {
1310
1317
*/
1311
1318
@ Nullable
1312
1319
public static Object getValue (Annotation annotation , String attributeName ) {
1313
- if (!StringUtils .hasText (attributeName )) {
1320
+ if (annotation == null || !StringUtils .hasText (attributeName )) {
1314
1321
return null ;
1315
1322
}
1316
1323
try {
@@ -1350,6 +1357,9 @@ public static Object getDefaultValue(Annotation annotation) {
1350
1357
*/
1351
1358
@ Nullable
1352
1359
public static Object getDefaultValue (Annotation annotation , String attributeName ) {
1360
+ if (annotation == null ) {
1361
+ return null ;
1362
+ }
1353
1363
return getDefaultValue (annotation .annotationType (), attributeName );
1354
1364
}
1355
1365
@@ -1375,7 +1385,7 @@ public static Object getDefaultValue(Class<? extends Annotation> annotationType)
1375
1385
*/
1376
1386
@ Nullable
1377
1387
public static Object getDefaultValue (Class <? extends Annotation > annotationType , String attributeName ) {
1378
- if (!StringUtils .hasText (attributeName )) {
1388
+ if (annotationType == null || !StringUtils .hasText (attributeName )) {
1379
1389
return null ;
1380
1390
}
1381
1391
try {
@@ -1430,7 +1440,7 @@ public static <A extends Annotation> A synthesizeAnnotation(
1430
1440
1431
1441
@ SuppressWarnings ("unchecked" )
1432
1442
static <A extends Annotation > A synthesizeAnnotation (A annotation , @ Nullable Object annotatedElement ) {
1433
- if (annotation instanceof SynthesizedAnnotation ) {
1443
+ if (annotation == null || annotation instanceof SynthesizedAnnotation ) {
1434
1444
return annotation ;
1435
1445
}
1436
1446
0 commit comments