CachedIntrospectionResults.clearClassLoader(null) removes cached classes for the system class loader

Issue: SPR-9189
This commit is contained in:
Juergen Hoeller
2013-01-16 10:24:05 +01:00
committed by unknown
parent e659deab4f
commit 6a5744e61c
2 changed files with 14 additions and 10 deletions

View File

@@ -18,9 +18,8 @@ package org.springframework.beans;
import java.beans.BeanInfo;
import java.beans.PropertyDescriptor;
import java.util.ArrayList;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.springframework.core.OverridingClassLoader;
@@ -37,7 +36,7 @@ import static org.junit.Assert.*;
public final class CachedIntrospectionResultsTests {
@Test
public void acceptClassLoader() throws Exception {
public void acceptAndClearClassLoader() throws Exception {
BeanWrapper bw = new BeanWrapperImpl(TestBean.class);
assertTrue(bw.isWritableProperty("name"));
assertTrue(bw.isWritableProperty("age"));
@@ -57,6 +56,14 @@ public final class CachedIntrospectionResultsTests {
assertTrue(CachedIntrospectionResults.classCache.containsKey(TestBean.class));
}
@Test
public void clearClassLoaderForSystemClassLoader() throws Exception {
BeanUtils.getPropertyDescriptors(ArrayList.class);
assertTrue(CachedIntrospectionResults.classCache.containsKey(ArrayList.class));
CachedIntrospectionResults.clearClassLoader(ArrayList.class.getClassLoader());
assertFalse(CachedIntrospectionResults.classCache.containsKey(ArrayList.class));
}
@Test
public void shouldUseExtendedBeanInfoWhenApplicable() throws NoSuchMethodException, SecurityException {
// given a class with a non-void returning setter method