@@ -295,7 +295,7 @@ private CachedIntrospectionResults(Class<?> beanClass) throws BeansException {
295
295
// Only allow URL attribute introspection, not content resolution
296
296
continue ;
297
297
}
298
- if (pd .getWriteMethod () == null && isInvalidReadOnlyPropertyType (pd .getPropertyType ())) {
298
+ if (pd .getWriteMethod () == null && isInvalidReadOnlyPropertyType (pd .getPropertyType (), beanClass )) {
299
299
// Ignore read-only properties such as ClassLoader - no need to bind to those
300
300
continue ;
301
301
}
@@ -345,7 +345,8 @@ private void introspectInterfaces(Class<?> beanClass, Class<?> currClass, Set<St
345
345
// GenericTypeAwarePropertyDescriptor leniently resolves a set* write method
346
346
// against a declared read method, so we prefer read method descriptors here.
347
347
pd = buildGenericTypeAwarePropertyDescriptor (beanClass , pd );
348
- if (pd .getWriteMethod () == null && isInvalidReadOnlyPropertyType (pd .getPropertyType ())) {
348
+ if (pd .getWriteMethod () == null &&
349
+ isInvalidReadOnlyPropertyType (pd .getPropertyType (), beanClass )) {
349
350
// Ignore read-only properties such as ClassLoader - no need to bind to those
350
351
continue ;
351
352
}
@@ -378,7 +379,7 @@ private boolean isPlainAccessor(Method method) {
378
379
if (Modifier .isStatic (method .getModifiers ()) ||
379
380
method .getDeclaringClass () == Object .class || method .getDeclaringClass () == Class .class ||
380
381
method .getParameterCount () > 0 || method .getReturnType () == void .class ||
381
- isInvalidReadOnlyPropertyType (method .getReturnType ())) {
382
+ isInvalidReadOnlyPropertyType (method .getReturnType (), method . getDeclaringClass () )) {
382
383
return false ;
383
384
}
384
385
try {
@@ -391,10 +392,11 @@ private boolean isPlainAccessor(Method method) {
391
392
}
392
393
}
393
394
394
- private boolean isInvalidReadOnlyPropertyType (@ Nullable Class <?> returnType ) {
395
- return (returnType != null && (AutoCloseable .class .isAssignableFrom (returnType ) ||
396
- ClassLoader .class .isAssignableFrom (returnType ) ||
397
- ProtectionDomain .class .isAssignableFrom (returnType )));
395
+ private boolean isInvalidReadOnlyPropertyType (@ Nullable Class <?> returnType , Class <?> beanClass ) {
396
+ return (returnType != null && (ClassLoader .class .isAssignableFrom (returnType ) ||
397
+ ProtectionDomain .class .isAssignableFrom (returnType ) ||
398
+ (AutoCloseable .class .isAssignableFrom (returnType ) &&
399
+ !AutoCloseable .class .isAssignableFrom (beanClass ))));
398
400
}
399
401
400
402
0 commit comments