From 2bd8c2bfca16e9324a71c5239514b8d7be0e908c Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 28 Dec 2017 12:52:40 +0100 Subject: [PATCH] Polish See gh-11181 --- .../source/SystemEnvironmentPropertyMapper.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SystemEnvironmentPropertyMapper.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SystemEnvironmentPropertyMapper.java index 74a13a4803..3f4ae6323b 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SystemEnvironmentPropertyMapper.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SystemEnvironmentPropertyMapper.java @@ -75,7 +75,9 @@ final class SystemEnvironmentPropertyMapper implements PropertyMapper { private String convertName(ConfigurationPropertyName name, int numberOfElements) { StringBuilder result = new StringBuilder(); for (int i = 0; i < numberOfElements; i++) { - result.append(result.length() == 0 ? "" : "_"); + if (result.length() > 0) { + result.append("_"); + } result.append(name.getElement(i, Form.UNIFORM).toUpperCase()); } return result.toString(); @@ -84,7 +86,9 @@ final class SystemEnvironmentPropertyMapper implements PropertyMapper { private String convertLegacyName(ConfigurationPropertyName name) { StringBuilder result = new StringBuilder(); for (int i = 0; i < name.getNumberOfElements(); i++) { - result.append(result.length() == 0 ? "" : "_"); + if (result.length() > 0) { + result.append("_"); + } result.append(convertLegacyNameElement(name.getElement(i, Form.ORIGINAL))); } return result.toString();