|
37 | 37 | import java.util.Set;
|
38 | 38 | import java.util.TreeSet;
|
39 | 39 | import java.util.concurrent.ConcurrentHashMap;
|
| 40 | +import java.util.concurrent.ConcurrentMap; |
40 | 41 |
|
41 | 42 | import org.springframework.beans.BeanUtils;
|
42 | 43 | import org.springframework.beans.BeanWrapper;
|
@@ -148,7 +149,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
148 | 149 | new ConcurrentHashMap<String, BeanWrapper>(16);
|
149 | 150 |
|
150 | 151 | /** Cache of filtered PropertyDescriptors: bean Class -> PropertyDescriptor array */
|
151 |
| - private final Map<Class<?>, PropertyDescriptor[]> filteredPropertyDescriptorsCache = |
| 152 | + private final ConcurrentMap<Class<?>, PropertyDescriptor[]> filteredPropertyDescriptorsCache = |
152 | 153 | new ConcurrentHashMap<Class<?>, PropertyDescriptor[]>(64);
|
153 | 154 |
|
154 | 155 |
|
@@ -1315,18 +1316,14 @@ protected String[] unsatisfiedNonSimpleProperties(AbstractBeanDefinition mbd, Be
|
1315 | 1316 | protected PropertyDescriptor[] filterPropertyDescriptorsForDependencyCheck(BeanWrapper bw, boolean cache) {
|
1316 | 1317 | PropertyDescriptor[] filtered = this.filteredPropertyDescriptorsCache.get(bw.getWrappedClass());
|
1317 | 1318 | if (filtered == null) {
|
| 1319 | + filtered = filterPropertyDescriptorsForDependencyCheck(bw); |
1318 | 1320 | if (cache) {
|
1319 |
| - synchronized (this.filteredPropertyDescriptorsCache) { |
1320 |
| - filtered = this.filteredPropertyDescriptorsCache.get(bw.getWrappedClass()); |
1321 |
| - if (filtered == null) { |
1322 |
| - filtered = filterPropertyDescriptorsForDependencyCheck(bw); |
1323 |
| - this.filteredPropertyDescriptorsCache.put(bw.getWrappedClass(), filtered); |
1324 |
| - } |
| 1321 | + PropertyDescriptor[] existing = |
| 1322 | + this.filteredPropertyDescriptorsCache.putIfAbsent(bw.getWrappedClass(), filtered); |
| 1323 | + if (existing != null) { |
| 1324 | + filtered = existing; |
1325 | 1325 | }
|
1326 | 1326 | }
|
1327 |
| - else { |
1328 |
| - filtered = filterPropertyDescriptorsForDependencyCheck(bw); |
1329 |
| - } |
1330 | 1327 | }
|
1331 | 1328 | return filtered;
|
1332 | 1329 | }
|
|
0 commit comments