AbstractApplicationContext resets common introspection caches after refresh

Issue: SPR-13093
master
Juergen Hoeller 9 years ago
parent f1d0368dd2
commit 06a5ed9cae
  1. 19
      spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java
  2. 12
      spring-core/src/main/java/org/springframework/core/ResolvableType.java

@ -32,6 +32,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.CachedIntrospectionResults;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
@ -536,6 +537,12 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
// Propagate exception to caller.
throw ex;
}
finally {
// Reset common introspection caches in Spring's core, since we
// might not ever need metadata for singleton beans anymore...
resetCommonCaches();
}
}
}
@ -840,6 +847,18 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
this.active.set(false);
}
/**
* Reset Spring's common core caches, in particular the {@link ResolvableType}
* and the {@link CachedIntrospectionResults} caches.
* @since 4.2
* @see ResolvableType#clearCache()
* @see CachedIntrospectionResults#clearClassLoader(ClassLoader)
*/
protected void resetCommonCaches() {
ResolvableType.clearCache();
CachedIntrospectionResults.clearClassLoader(getClassLoader());
}
/**
* Register a shutdown hook with the JVM runtime, closing this context

@ -1307,11 +1307,19 @@ public class ResolvableType implements Serializable {
return resolvableType;
}
/**
* Clear the internal {@code ResolvableType} cache.
* @since 4.2
*/
public static void clearCache() {
cache.clear();
}
/**
* Strategy interface used to resolve {@link TypeVariable}s.
*/
static interface VariableResolver extends Serializable {
interface VariableResolver extends Serializable {
/**
* Return the source of the resolver (used for hashCode and equals).
@ -1481,7 +1489,7 @@ public class ResolvableType implements Serializable {
/**
* The various kinds of bounds.
*/
static enum Kind {UPPER, LOWER}
enum Kind {UPPER, LOWER}
}
}

Loading…
Cancel
Save