@@ -270,7 +270,7 @@ private CachedIntrospectionResults(Class<?> beanClass) throws BeansException {
270
270
// Only allow URL attribute introspection, not content resolution
271
271
continue ;
272
272
}
273
- if (pd .getWriteMethod () == null && isInvalidReadOnlyPropertyType (pd .getPropertyType ())) {
273
+ if (pd .getWriteMethod () == null && isInvalidReadOnlyPropertyType (pd .getPropertyType (), beanClass )) {
274
274
// Ignore read-only properties such as ClassLoader - no need to bind to those
275
275
continue ;
276
276
}
@@ -320,7 +320,8 @@ private void introspectInterfaces(Class<?> beanClass, Class<?> currClass, Set<St
320
320
// GenericTypeAwarePropertyDescriptor leniently resolves a set* write method
321
321
// against a declared read method, so we prefer read method descriptors here.
322
322
pd = buildGenericTypeAwarePropertyDescriptor (beanClass , pd );
323
- if (pd .getWriteMethod () == null && isInvalidReadOnlyPropertyType (pd .getPropertyType ())) {
323
+ if (pd .getWriteMethod () == null &&
324
+ isInvalidReadOnlyPropertyType (pd .getPropertyType (), beanClass )) {
324
325
// Ignore read-only properties such as ClassLoader - no need to bind to those
325
326
continue ;
326
327
}
@@ -353,7 +354,7 @@ private boolean isPlainAccessor(Method method) {
353
354
if (Modifier .isStatic (method .getModifiers ()) ||
354
355
method .getDeclaringClass () == Object .class || method .getDeclaringClass () == Class .class ||
355
356
method .getParameterCount () > 0 || method .getReturnType () == void .class ||
356
- isInvalidReadOnlyPropertyType (method .getReturnType ())) {
357
+ isInvalidReadOnlyPropertyType (method .getReturnType (), method . getDeclaringClass () )) {
357
358
return false ;
358
359
}
359
360
try {
@@ -366,10 +367,11 @@ private boolean isPlainAccessor(Method method) {
366
367
}
367
368
}
368
369
369
- private boolean isInvalidReadOnlyPropertyType (@ Nullable Class <?> returnType ) {
370
- return (returnType != null && (AutoCloseable .class .isAssignableFrom (returnType ) ||
371
- ClassLoader .class .isAssignableFrom (returnType ) ||
372
- ProtectionDomain .class .isAssignableFrom (returnType )));
370
+ private boolean isInvalidReadOnlyPropertyType (@ Nullable Class <?> returnType , Class <?> beanClass ) {
371
+ return (returnType != null && (ClassLoader .class .isAssignableFrom (returnType ) ||
372
+ ProtectionDomain .class .isAssignableFrom (returnType ) ||
373
+ (AutoCloseable .class .isAssignableFrom (returnType ) &&
374
+ !AutoCloseable .class .isAssignableFrom (beanClass ))));
373
375
}
374
376
375
377
0 commit comments