Skip to content

Commit

Permalink
ReflectivePropertyAccessor uses computeIfAbsent for cache computation
Browse files Browse the repository at this point in the history
Issue: SPR-16882
  • Loading branch information
jhoeller committed Jun 10, 2018
1 parent b71795b commit e2ccd55
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -436,13 +436,11 @@ protected boolean isCandidateForProperty(Method method, Class<?> targetClass) {
* 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;
});
}

/**
Expand Down

0 comments on commit e2ccd55

Please sign in to comment.