diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeElementMembers.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeElementMembers.java index b78fbc1074..6487704e7d 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeElementMembers.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeElementMembers.java @@ -104,11 +104,7 @@ class TypeElementMembers { else if (isSetter(method)) { String propertyName = getAccessorName(name); List matchingSetters = this.publicSetters - .get(propertyName); - if (matchingSetters == null) { - matchingSetters = new ArrayList<>(); - this.publicSetters.put(propertyName, matchingSetters); - } + .computeIfAbsent(propertyName, (k) -> new ArrayList<>()); TypeMirror paramType = method.getParameters().get(0).asType(); if (getMatchingSetter(matchingSetters, paramType) == null) { matchingSetters.add(method); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ConfigurationMetadata.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ConfigurationMetadata.java index 8689ba1059..7389ba4868 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ConfigurationMetadata.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ConfigurationMetadata.java @@ -136,11 +136,7 @@ public class ConfigurationMetadata { } private void add(Map> map, K key, V value) { - List values = map.get(key); - if (values == null) { - values = new ArrayList<>(); - map.put(key, values); - } + List values = map.computeIfAbsent(key, (k) -> new ArrayList<>()); values.add(value); }