|
1 | 1 | /* |
2 | | - * Copyright 2002-2020 the original author or authors. |
| 2 | + * Copyright 2002-2022 the original author or authors. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
|
22 | 22 | import java.beans.PropertyDescriptor; |
23 | 23 | import java.lang.reflect.Method; |
24 | 24 | import java.lang.reflect.Modifier; |
| 25 | +import java.security.ProtectionDomain; |
25 | 26 | import java.util.Collections; |
26 | 27 | import java.util.HashSet; |
27 | 28 | import java.util.LinkedHashMap; |
@@ -286,9 +287,13 @@ private CachedIntrospectionResults(Class<?> beanClass) throws BeansException { |
286 | 287 | // This call is slow so we do it once. |
287 | 288 | PropertyDescriptor[] pds = this.beanInfo.getPropertyDescriptors(); |
288 | 289 | for (PropertyDescriptor pd : pds) { |
289 | | - if (Class.class == beanClass && |
290 | | - ("classLoader".equals(pd.getName()) || "protectionDomain".equals(pd.getName()))) { |
291 | | - // Ignore Class.getClassLoader() and getProtectionDomain() methods - nobody needs to bind to those |
| 290 | + if (Class.class == beanClass && (!"name".equals(pd.getName()) && !pd.getName().endsWith("Name"))) { |
| 291 | + // Only allow all name variants of Class properties |
| 292 | + continue; |
| 293 | + } |
| 294 | + if (pd.getPropertyType() != null && (ClassLoader.class.isAssignableFrom(pd.getPropertyType()) |
| 295 | + || ProtectionDomain.class.isAssignableFrom(pd.getPropertyType()))) { |
| 296 | + // Ignore ClassLoader and ProtectionDomain types - nobody needs to bind to those |
292 | 297 | continue; |
293 | 298 | } |
294 | 299 | if (logger.isTraceEnabled()) { |
@@ -337,6 +342,11 @@ private void introspectInterfaces(Class<?> beanClass, Class<?> currClass, Set<St |
337 | 342 | // GenericTypeAwarePropertyDescriptor leniently resolves a set* write method |
338 | 343 | // against a declared read method, so we prefer read method descriptors here. |
339 | 344 | pd = buildGenericTypeAwarePropertyDescriptor(beanClass, pd); |
| 345 | + if (pd.getPropertyType() != null && (ClassLoader.class.isAssignableFrom(pd.getPropertyType()) |
| 346 | + || ProtectionDomain.class.isAssignableFrom(pd.getPropertyType()))) { |
| 347 | + // Ignore ClassLoader and ProtectionDomain types - nobody needs to bind to those |
| 348 | + continue; |
| 349 | + } |
340 | 350 | this.propertyDescriptors.put(pd.getName(), pd); |
341 | 351 | Method readMethod = pd.getReadMethod(); |
342 | 352 | if (readMethod != null) { |
|
0 commit comments