File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
spring-core/src/main/java/org/springframework/util Expand file tree Collapse file tree 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 {
5151 */
5252 private static final String CGLIB_RENAMED_METHOD_PREFIX = "CGLIB$" ;
5353
54+ private static final Method [] NO_METHODS = {};
55+
56+ private static final Field [] NO_FIELDS = {};
57+
5458 /**
5559 * Cache for {@link Class#getDeclaredMethods()} plus equivalent default methods
5660 * from Java 8 based interfaces, allowing for fast iteration.
@@ -617,7 +621,7 @@ private static Method[] getDeclaredMethods(Class<?> clazz) {
617621 else {
618622 result = declaredMethods ;
619623 }
620- declaredMethodsCache .put (clazz , result );
624+ declaredMethodsCache .put (clazz , ( result . length == 0 ? NO_METHODS : result ) );
621625 }
622626 return result ;
623627 }
@@ -705,7 +709,7 @@ private static Field[] getDeclaredFields(Class<?> clazz) {
705709 Field [] result = declaredFieldsCache .get (clazz );
706710 if (result == null ) {
707711 result = clazz .getDeclaredFields ();
708- declaredFieldsCache .put (clazz , result );
712+ declaredFieldsCache .put (clazz , ( result . length == 0 ? NO_FIELDS : result ) );
709713 }
710714 return result ;
711715 }
You can’t perform that action at this time.
0 commit comments