ReflectivePropertyAccessor uses computeIfAbsent for cache computation

Issue: SPR-16882
This commit is contained in:
Juergen Hoeller 2018-06-10 23:56:32 +02:00
parent b71795ba36
commit e2ccd55d14
1 changed files with 4 additions and 6 deletions

View File

@ -436,13 +436,11 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
* Return class methods ordered with non-bridge methods appearing higher.
*/
private Method[] getSortedMethods(Class<?> clazz) {
Method[] methods = this.sortedMethodsCache.get(clazz);
if (methods == null) {
methods = clazz.getMethods();
return this.sortedMethodsCache.computeIfAbsent(clazz, key -> {
Method[] methods = key.getMethods();
Arrays.sort(methods, (o1, o2) -> (o1.isBridge() == o2.isBridge() ? 0 : (o1.isBridge() ? 1 : -1)));
this.sortedMethodsCache.put(clazz, methods);
}
return methods;
return methods;
});
}
/**