diff --git a/module/spring-boot-mustache/src/main/java/org/springframework/boot/mustache/autoconfigure/MustacheProperties.java b/module/spring-boot-mustache/src/main/java/org/springframework/boot/mustache/autoconfigure/MustacheProperties.java index 558d90b9e493..9ffe0d4a36de 100644 --- a/module/spring-boot-mustache/src/main/java/org/springframework/boot/mustache/autoconfigure/MustacheProperties.java +++ b/module/spring-boot-mustache/src/main/java/org/springframework/boot/mustache/autoconfigure/MustacheProperties.java @@ -124,6 +124,12 @@ public Charset getCharset() { return this.charset; } + /** + * Get the charset name. + * @return the charset name + * @deprecated since 4.1.0 in favor of {@link #getCharset()} + */ + @Deprecated(since = "4.1.0") public String getCharsetName() { return this.charset.name(); } diff --git a/module/spring-boot-mustache/src/main/java/org/springframework/boot/mustache/autoconfigure/MustacheResourceTemplateLoader.java b/module/spring-boot-mustache/src/main/java/org/springframework/boot/mustache/autoconfigure/MustacheResourceTemplateLoader.java index b388ff0b33c3..094b69c18f3e 100644 --- a/module/spring-boot-mustache/src/main/java/org/springframework/boot/mustache/autoconfigure/MustacheResourceTemplateLoader.java +++ b/module/spring-boot-mustache/src/main/java/org/springframework/boot/mustache/autoconfigure/MustacheResourceTemplateLoader.java @@ -18,6 +18,8 @@ import java.io.InputStreamReader; import java.io.Reader; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import com.samskivert.mustache.Mustache; import com.samskivert.mustache.Mustache.Compiler; @@ -45,7 +47,7 @@ public class MustacheResourceTemplateLoader implements TemplateLoader, ResourceL private String suffix = ""; - private String charSet = "UTF-8"; + private Charset charSet = StandardCharsets.UTF_8; private ResourceLoader resourceLoader = new DefaultResourceLoader(null); @@ -60,8 +62,19 @@ public MustacheResourceTemplateLoader(String prefix, String suffix) { /** * Set the charset. * @param charSet the charset + * @deprecated since 4.1.0 in favor of {@link #setCharset(Charset)} */ + @Deprecated(since = "4.1.0") public void setCharset(String charSet) { + this.charSet = Charset.forName(charSet); + } + + /** + * Set the charset. + * @param charSet the charset + * @since 4.1.0 + */ + public void setCharset(Charset charSet) { this.charSet = charSet; }