Skip to content

Commit 5ab83d8

Browse files
author
dj.lee2
committed
Use Charset instead of String for Mustache template encoding
The MustacheResourceTemplateLoader previously defined the template encoding as a String, defaulting to "UTF-8". This change replaces the field with a Charset and initializes it with StandardCharsets.UTF_8. Using Charset improves type safety and aligns with modern Spring Boot standards, while avoiding implicit charset lookup issues. Signed-off-by: dj.lee2 <dj.lee2@okestro.com>
1 parent 811ddcd commit 5ab83d8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

module/spring-boot-mustache/src/main/java/org/springframework/boot/mustache/autoconfigure/MustacheResourceTemplateLoader.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
import java.io.InputStreamReader;
2020
import java.io.Reader;
21+
import java.nio.charset.Charset;
22+
import java.nio.charset.StandardCharsets;
2123

2224
import com.samskivert.mustache.Mustache;
2325
import com.samskivert.mustache.Mustache.Compiler;
@@ -45,7 +47,7 @@ public class MustacheResourceTemplateLoader implements TemplateLoader, ResourceL
4547

4648
private String suffix = "";
4749

48-
private String charSet = "UTF-8";
50+
private Charset charSet = StandardCharsets.UTF_8;
4951

5052
private ResourceLoader resourceLoader = new DefaultResourceLoader(null);
5153

@@ -61,7 +63,7 @@ public MustacheResourceTemplateLoader(String prefix, String suffix) {
6163
* Set the charset.
6264
* @param charSet the charset
6365
*/
64-
public void setCharset(String charSet) {
66+
public void setCharset(Charset charSet) {
6567
this.charSet = charSet;
6668
}
6769

0 commit comments

Comments
 (0)