Merge branch '5.3.x'

This commit is contained in:
Brian Clozel 2022-03-31 10:33:51 +02:00
commit afbff391d8
1 changed files with 14 additions and 4 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,6 +22,7 @@ import java.beans.Introspector;
import java.beans.PropertyDescriptor; import java.beans.PropertyDescriptor;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.security.ProtectionDomain;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@ -286,9 +287,13 @@ public final class CachedIntrospectionResults {
// This call is slow so we do it once. // This call is slow so we do it once.
PropertyDescriptor[] pds = this.beanInfo.getPropertyDescriptors(); PropertyDescriptor[] pds = this.beanInfo.getPropertyDescriptors();
for (PropertyDescriptor pd : pds) { for (PropertyDescriptor pd : pds) {
if (Class.class == beanClass && if (Class.class == beanClass && (!"name".equals(pd.getName()) && !pd.getName().endsWith("Name"))) {
("classLoader".equals(pd.getName()) || "protectionDomain".equals(pd.getName()))) { // Only allow all name variants of Class properties
// Ignore Class.getClassLoader() and getProtectionDomain() methods - nobody needs to bind to those continue;
}
if (pd.getPropertyType() != null && (ClassLoader.class.isAssignableFrom(pd.getPropertyType())
|| ProtectionDomain.class.isAssignableFrom(pd.getPropertyType()))) {
// Ignore ClassLoader and ProtectionDomain types - nobody needs to bind to those
continue; continue;
} }
if (logger.isTraceEnabled()) { if (logger.isTraceEnabled()) {
@ -337,6 +342,11 @@ public final class CachedIntrospectionResults {
// GenericTypeAwarePropertyDescriptor leniently resolves a set* write method // GenericTypeAwarePropertyDescriptor leniently resolves a set* write method
// against a declared read method, so we prefer read method descriptors here. // against a declared read method, so we prefer read method descriptors here.
pd = buildGenericTypeAwarePropertyDescriptor(beanClass, pd); pd = buildGenericTypeAwarePropertyDescriptor(beanClass, pd);
if (pd.getPropertyType() != null && (ClassLoader.class.isAssignableFrom(pd.getPropertyType())
|| ProtectionDomain.class.isAssignableFrom(pd.getPropertyType()))) {
// Ignore ClassLoader and ProtectionDomain types - nobody needs to bind to those
continue;
}
this.propertyDescriptors.put(pd.getName(), pd); this.propertyDescriptors.put(pd.getName(), pd);
Method readMethod = pd.getReadMethod(); Method readMethod = pd.getReadMethod();
if (readMethod != null) { if (readMethod != null) {