diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemMetadata.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemMetadata.java index 88eb70334a1..8871d60b9da 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemMetadata.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemMetadata.java @@ -58,14 +58,17 @@ public final class ItemMetadata implements Comparable { } private String buildName(String prefix, String name) { - while (prefix != null && prefix.endsWith(".")) { - prefix = prefix.substring(0, prefix.length() - 1); - } - StringBuilder fullName = new StringBuilder((prefix != null) ? prefix : ""); - if (fullName.length() > 0 && name != null) { - fullName.append('.'); + StringBuilder fullName = new StringBuilder(); + if (prefix != null) { + if (prefix.endsWith(".")) { + prefix = prefix.substring(0, prefix.length() - 1); + } + fullName.append(prefix); } if (name != null) { + if (fullName.length() > 0) { + fullName.append('.'); + } fullName.append(ConfigurationMetadata.toDashedCase(name)); } return fullName.toString();