From 85e71f237391bdeb81cb00954f890ecd8b294823 Mon Sep 17 00:00:00 2001 From: Thiago Hirata Date: Mon, 9 Oct 2017 18:35:35 +0000 Subject: [PATCH] Update OriginTrackedPropertiesLoader to ISO 8859-1 Align `OriginTrackedPropertiesLoader` with Java default property loading by using ISO 8859-1 character encoding. Closes gh-10565 --- .../boot/env/OriginTrackedPropertiesLoader.java | 3 ++- .../boot/env/OriginTrackedPropertiesLoaderTests.java | 6 ++++++ .../org/springframework/boot/env/test-properties.properties | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/OriginTrackedPropertiesLoader.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/OriginTrackedPropertiesLoader.java index 3e0e06c1e2..b18a5f8646 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/OriginTrackedPropertiesLoader.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/OriginTrackedPropertiesLoader.java @@ -37,6 +37,7 @@ import org.springframework.util.Assert; * * @author Madhura Bhave * @author Phillip Webb + * @author Thiago Hirata */ class OriginTrackedPropertiesLoader { @@ -154,7 +155,7 @@ class OriginTrackedPropertiesLoader { CharacterReader(Resource resource) throws IOException { this.reader = new LineNumberReader( - new InputStreamReader(resource.getInputStream())); + new InputStreamReader(resource.getInputStream(), "8859_1")); } @Override diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/OriginTrackedPropertiesLoaderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/OriginTrackedPropertiesLoaderTests.java index 77eff0c05c..db90db45cc 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/OriginTrackedPropertiesLoaderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/OriginTrackedPropertiesLoaderTests.java @@ -228,6 +228,12 @@ public class OriginTrackedPropertiesLoaderTests { assertThat(getLocation(mango)).isEqualTo("27:1"); } + @Test + public void getPropertyWithISO88591Character() throws Exception { + OriginTrackedValue value = this.properties.get("test-iso8859-1-chars"); + assertThat(getValue(value)).isEqualTo("æ×ÈÅÞßáñÀÿ"); + } + private Object getValue(OriginTrackedValue value) { return (value == null ? null : value.getValue()); } diff --git a/spring-boot-project/spring-boot/src/test/resources/org/springframework/boot/env/test-properties.properties b/spring-boot-project/spring-boot/src/test/resources/org/springframework/boot/env/test-properties.properties index 19dabb34fb..245f30a114 100644 --- a/spring-boot-project/spring-boot/src/test/resources/org/springframework/boot/env/test-properties.properties +++ b/spring-boot-project/spring-boot/src/test/resources/org/springframework/boot/env/test-properties.properties @@ -37,3 +37,6 @@ test-property-value-comment=foo \ !bar #foo test-multiline-immediate-bang=\ !foo + +#test ISO 8859-1 +test-iso8859-1-chars=æ×ÈÅÞßáñÀÿ \ No newline at end of file