Skip to content

Commit 564e165

Browse files
jhoellerBenjamin Reed
authored and
Benjamin Reed
committed
Restore ability to configure setClassLoader methods
Closes spring-projectsgh-28269
1 parent c38095a commit 564e165

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

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

+10-7
Original file line numberDiff line numberDiff line change
@@ -244,13 +244,15 @@ private CachedIntrospectionResults(Class beanClass) throws BeansException {
244244
// This call is slow so we do it once.
245245
PropertyDescriptor[] pds = this.beanInfo.getPropertyDescriptors();
246246
for (PropertyDescriptor pd : pds) {
247-
if (Class.class == beanClass && (!"name".equals(pd.getName()) && !pd.getName().endsWith("Name"))) {
247+
if (Class.class == beanClass && !("name".equals(pd.getName()) ||
248+
(pd.getName().endsWith("Name") && String.class == pd.getPropertyType()))) {
248249
// Only allow all name variants of Class properties
249250
continue;
250251
}
251-
if (pd.getPropertyType() != null && (ClassLoader.class.isAssignableFrom(pd.getPropertyType())
252-
|| ProtectionDomain.class.isAssignableFrom(pd.getPropertyType()))) {
253-
// Ignore ClassLoader and ProtectionDomain types - nobody needs to bind to those
252+
if (pd.getWriteMethod() == null && pd.getPropertyType() != null &&
253+
(ClassLoader.class.isAssignableFrom(pd.getPropertyType()) ||
254+
ProtectionDomain.class.isAssignableFrom(pd.getPropertyType()))) {
255+
// Ignore ClassLoader and ProtectionDomain read-only properties - no need to bind to those
254256
continue;
255257
}
256258
if (logger.isTraceEnabled()) {
@@ -260,9 +262,10 @@ private CachedIntrospectionResults(Class beanClass) throws BeansException {
260262
"; editor [" + pd.getPropertyEditorClass().getName() + "]" : ""));
261263
}
262264
pd = buildGenericTypeAwarePropertyDescriptor(beanClass, pd);
263-
if (pd.getPropertyType() != null && (ClassLoader.class.isAssignableFrom(pd.getPropertyType())
264-
|| ProtectionDomain.class.isAssignableFrom(pd.getPropertyType()))) {
265-
// Ignore ClassLoader and ProtectionDomain types - nobody needs to bind to those
265+
if (pd.getWriteMethod() == null && pd.getPropertyType() != null &&
266+
(ClassLoader.class.isAssignableFrom(pd.getPropertyType()) ||
267+
ProtectionDomain.class.isAssignableFrom(pd.getPropertyType()))) {
268+
// Ignore ClassLoader and ProtectionDomain read-only properties - no need to bind to those
266269
continue;
267270
}
268271
this.propertyDescriptorCache.put(pd.getName(), pd);

0 commit comments

Comments
 (0)