File tree 1 file changed +6
-2
lines changed
spring-core/src/main/java/org/springframework/util
1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,10 @@ public abstract class ReflectionUtils {
51
51
*/
52
52
private static final String CGLIB_RENAMED_METHOD_PREFIX = "CGLIB$" ;
53
53
54
+ private static final Method [] NO_METHODS = {};
55
+
56
+ private static final Field [] NO_FIELDS = {};
57
+
54
58
/**
55
59
* Cache for {@link Class#getDeclaredMethods()} plus equivalent default methods
56
60
* from Java 8 based interfaces, allowing for fast iteration.
@@ -617,7 +621,7 @@ private static Method[] getDeclaredMethods(Class<?> clazz) {
617
621
else {
618
622
result = declaredMethods ;
619
623
}
620
- declaredMethodsCache .put (clazz , result );
624
+ declaredMethodsCache .put (clazz , ( result . length == 0 ? NO_METHODS : result ) );
621
625
}
622
626
return result ;
623
627
}
@@ -705,7 +709,7 @@ private static Field[] getDeclaredFields(Class<?> clazz) {
705
709
Field [] result = declaredFieldsCache .get (clazz );
706
710
if (result == null ) {
707
711
result = clazz .getDeclaredFields ();
708
- declaredFieldsCache .put (clazz , result );
712
+ declaredFieldsCache .put (clazz , ( result . length == 0 ? NO_FIELDS : result ) );
709
713
}
710
714
return result ;
711
715
}
You can’t perform that action at this time.
0 commit comments