@@ -83,7 +83,10 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
83
83
private final Map <PropertyCacheKey , TypeDescriptor > typeDescriptorCache =
84
84
new ConcurrentHashMap <PropertyCacheKey , TypeDescriptor >(64 );
85
85
86
- private InvokerPair lastReadInvokerPair ;
86
+ private final Map <Class <?>, Method []> sortedMethodsCache =
87
+ new ConcurrentHashMap <Class <?>, Method []>(64 );
88
+
89
+ private volatile InvokerPair lastReadInvokerPair ;
87
90
88
91
89
92
/**
@@ -277,6 +280,7 @@ public void write(EvaluationContext context, Object target, String name, Object
277
280
throw new AccessException ("Type conversion failure" , evaluationException );
278
281
}
279
282
}
283
+
280
284
PropertyCacheKey cacheKey = new PropertyCacheKey (type , name , target instanceof Class );
281
285
Member cachedMember = this .writerCache .get (cacheKey );
282
286
@@ -400,7 +404,7 @@ protected Method findSetterForProperty(String propertyName, Class<?> clazz, bool
400
404
private Method findMethodForProperty (String [] methodSuffixes , String prefix , Class <?> clazz ,
401
405
boolean mustBeStatic , int numberOfParams , Set <Class <?>> requiredReturnTypes ) {
402
406
403
- Method [] methods = getSortedClassMethods (clazz );
407
+ Method [] methods = getSortedMethods (clazz );
404
408
for (String methodSuffix : methodSuffixes ) {
405
409
for (Method method : methods ) {
406
410
if (isCandidateForProperty (method , clazz ) && method .getName ().equals (prefix + methodSuffix ) &&
@@ -428,16 +432,20 @@ protected boolean isCandidateForProperty(Method method, Class<?> targetClass) {
428
432
}
429
433
430
434
/**
431
- * Return class methods ordered with non bridge methods appearing higher.
435
+ * Return class methods ordered with non- bridge methods appearing higher.
432
436
*/
433
- private Method [] getSortedClassMethods (Class <?> clazz ) {
434
- Method [] methods = clazz .getMethods ();
435
- Arrays .sort (methods , new Comparator <Method >() {
436
- @ Override
437
- public int compare (Method o1 , Method o2 ) {
438
- return (o1 .isBridge () == o2 .isBridge ()) ? 0 : (o1 .isBridge () ? 1 : -1 );
439
- }
440
- });
437
+ private Method [] getSortedMethods (Class <?> clazz ) {
438
+ Method [] methods = this .sortedMethodsCache .get (clazz );
439
+ if (methods == null ) {
440
+ methods = clazz .getMethods ();
441
+ Arrays .sort (methods , new Comparator <Method >() {
442
+ @ Override
443
+ public int compare (Method o1 , Method o2 ) {
444
+ return (o1 .isBridge () == o2 .isBridge ()) ? 0 : (o1 .isBridge () ? 1 : -1 );
445
+ }
446
+ });
447
+ this .sortedMethodsCache .put (clazz , methods );
448
+ }
441
449
return methods ;
442
450
}
443
451
0 commit comments