Skip to content

Commit e2ccd55

Browse files
committed
ReflectivePropertyAccessor uses computeIfAbsent for cache computation
Issue: SPR-16882
1 parent b71795b commit e2ccd55

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectivePropertyAccessor.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -436,13 +436,11 @@ protected boolean isCandidateForProperty(Method method, Class<?> targetClass) {
436436
* Return class methods ordered with non-bridge methods appearing higher.
437437
*/
438438
private Method[] getSortedMethods(Class<?> clazz) {
439-
Method[] methods = this.sortedMethodsCache.get(clazz);
440-
if (methods == null) {
441-
methods = clazz.getMethods();
439+
return this.sortedMethodsCache.computeIfAbsent(clazz, key -> {
440+
Method[] methods = key.getMethods();
442441
Arrays.sort(methods, (o1, o2) -> (o1.isBridge() == o2.isBridge() ? 0 : (o1.isBridge() ? 1 : -1)));
443-
this.sortedMethodsCache.put(clazz, methods);
444-
}
445-
return methods;
442+
return methods;
443+
});
446444
}
447445

448446
/**

0 commit comments

Comments
 (0)