Skip to content

Commit fdc14a1

Browse files
committed
AbstractApplicationContext clears ReflectionUtils cache as well
Issue: SPR-13783
1 parent 78dad4c commit fdc14a1

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
import org.springframework.core.io.support.ResourcePatternResolver;
7878
import org.springframework.util.Assert;
7979
import org.springframework.util.ObjectUtils;
80+
import org.springframework.util.ReflectionUtils;
8081

8182
/**
8283
* Abstract implementation of the {@link org.springframework.context.ApplicationContext}
@@ -867,13 +868,15 @@ protected void cancelRefresh(BeansException ex) {
867868
}
868869

869870
/**
870-
* Reset Spring's common core caches, in particular the {@link ResolvableType}
871-
* and the {@link CachedIntrospectionResults} caches.
871+
* Reset Spring's common core caches, in particular the {@link ReflectionUtils},
872+
* {@link ResolvableType} and {@link CachedIntrospectionResults} caches.
872873
* @since 4.2
874+
* @see ReflectionUtils#clearCache()
873875
* @see ResolvableType#clearCache()
874876
* @see CachedIntrospectionResults#clearClassLoader(ClassLoader)
875877
*/
876878
protected void resetCommonCaches() {
879+
ReflectionUtils.clearCache();
877880
ResolvableType.clearCache();
878881
CachedIntrospectionResults.clearClassLoader(getClassLoader());
879882
}

spring-core/src/main/java/org/springframework/util/ReflectionUtils.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,15 @@ public void doWith(Field field) throws IllegalArgumentException, IllegalAccessEx
739739
}, COPYABLE_FIELDS);
740740
}
741741

742+
/**
743+
* Clear the internal method/field cache.
744+
* @since 4.2.4
745+
*/
746+
public static void clearCache() {
747+
declaredMethodsCache.clear();
748+
declaredFieldsCache.clear();
749+
}
750+
742751

743752
/**
744753
* Action to take on each method.

0 commit comments

Comments
 (0)