Skip to content

Commit 39094e3

Browse files
jhoellerBenjamin Reed
authored andcommitted
Restore ability to configure setClassLoader methods
Closes spring-projectsgh-28269
1 parent 77cec30 commit 39094e3

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -289,13 +289,15 @@ private CachedIntrospectionResults(Class<?> beanClass) throws BeansException {
289289
// This call is slow so we do it once.
290290
PropertyDescriptor[] pds = this.beanInfo.getPropertyDescriptors();
291291
for (PropertyDescriptor pd : pds) {
292-
if (Class.class == beanClass && (!"name".equals(pd.getName()) && !pd.getName().endsWith("Name"))) {
292+
if (Class.class == beanClass && !("name".equals(pd.getName()) ||
293+
(pd.getName().endsWith("Name") && String.class == pd.getPropertyType()))) {
293294
// Only allow all name variants of Class properties
294295
continue;
295296
}
296-
if (pd.getPropertyType() != null && (ClassLoader.class.isAssignableFrom(pd.getPropertyType())
297-
|| ProtectionDomain.class.isAssignableFrom(pd.getPropertyType()))) {
298-
// Ignore ClassLoader and ProtectionDomain types - nobody needs to bind to those
297+
if (pd.getWriteMethod() == null && pd.getPropertyType() != null &&
298+
(ClassLoader.class.isAssignableFrom(pd.getPropertyType()) ||
299+
ProtectionDomain.class.isAssignableFrom(pd.getPropertyType()))) {
300+
// Ignore ClassLoader and ProtectionDomain read-only properties - no need to bind to those
299301
continue;
300302
}
301303
if (logger.isTraceEnabled()) {
@@ -305,9 +307,10 @@ private CachedIntrospectionResults(Class<?> beanClass) throws BeansException {
305307
"; editor [" + pd.getPropertyEditorClass().getName() + "]" : ""));
306308
}
307309
pd = buildGenericTypeAwarePropertyDescriptor(beanClass, pd);
308-
if (pd.getPropertyType() != null && (ClassLoader.class.isAssignableFrom(pd.getPropertyType())
309-
|| ProtectionDomain.class.isAssignableFrom(pd.getPropertyType()))) {
310-
// Ignore ClassLoader and ProtectionDomain types - nobody needs to bind to those
310+
if (pd.getWriteMethod() == null && pd.getPropertyType() != null &&
311+
(ClassLoader.class.isAssignableFrom(pd.getPropertyType()) ||
312+
ProtectionDomain.class.isAssignableFrom(pd.getPropertyType()))) {
313+
// Ignore ClassLoader and ProtectionDomain read-only properties - no need to bind to those
311314
continue;
312315
}
313316
this.propertyDescriptorCache.put(pd.getName(), pd);

0 commit comments

Comments
 (0)