Skip to content

Commit 7f89522

Browse files
committed
Revised exclusion of java.lang.Class properties
Issue: SPR-11098 (cherry picked from commit 62ea627)
1 parent 22ece06 commit 7f89522

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

spring-beans/src/main/java/org/springframework/beans/CachedIntrospectionResults.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public class CachedIntrospectionResults {
7676
* Needs to be a WeakHashMap with WeakReferences as values to allow
7777
* for proper garbage collection in case of multiple class loaders.
7878
*/
79-
static final Map<Class, Object> classCache = new WeakHashMap<Class, Object>();
79+
static final Map<Class<?>, Object> classCache = new WeakHashMap<Class<?>, Object>();
8080

8181

8282
/**
@@ -107,7 +107,7 @@ public static void acceptClassLoader(ClassLoader classLoader) {
107107
*/
108108
public static void clearClassLoader(ClassLoader classLoader) {
109109
synchronized (classCache) {
110-
for (Iterator<Class> it = classCache.keySet().iterator(); it.hasNext();) {
110+
for (Iterator<Class<?>> it = classCache.keySet().iterator(); it.hasNext();) {
111111
Class<?> beanClass = it.next();
112112
if (isUnderneathClassLoader(beanClass.getClassLoader(), classLoader)) {
113113
it.remove();
@@ -130,15 +130,16 @@ public static void clearClassLoader(ClassLoader classLoader) {
130130
* @return the corresponding CachedIntrospectionResults
131131
* @throws BeansException in case of introspection failure
132132
*/
133+
@SuppressWarnings("unchecked")
133134
static CachedIntrospectionResults forClass(Class<?> beanClass) throws BeansException {
134135
CachedIntrospectionResults results;
135136
Object value;
136137
synchronized (classCache) {
137138
value = classCache.get(beanClass);
138139
}
139140
if (value instanceof Reference) {
140-
Reference ref = (Reference) value;
141-
results = (CachedIntrospectionResults) ref.get();
141+
Reference<CachedIntrospectionResults> ref = (Reference<CachedIntrospectionResults>) value;
142+
results = ref.get();
142143
}
143144
else {
144145
results = (CachedIntrospectionResults) value;
@@ -260,8 +261,9 @@ private CachedIntrospectionResults(Class<?> beanClass) throws BeansException {
260261
// This call is slow so we do it once.
261262
PropertyDescriptor[] pds = this.beanInfo.getPropertyDescriptors();
262263
for (PropertyDescriptor pd : pds) {
263-
if (Class.class.equals(beanClass) && "classLoader".equals(pd.getName())) {
264-
// Ignore Class.getClassLoader() method - nobody needs to bind to that
264+
if (Class.class.equals(beanClass) &&
265+
("classLoader".equals(pd.getName()) || "protectionDomain".equals(pd.getName()))) {
266+
// Ignore Class.getClassLoader() and getProtectionDomain() methods - nobody needs to bind to those
265267
continue;
266268
}
267269
if (logger.isTraceEnabled()) {

0 commit comments

Comments
 (0)