Use Charset instead of String for Mustache template encoding by ddongjunn · Pull Request #48347 · spring-projects/spring-boot

@ddongjunn

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: djlee <ddongjunn@gmail.com>

@ddongjunn

Add setCharset(Charset) overload to MustacheResourceTemplateLoader
while keeping setCharset(String) for backward compatibility. The
String-based method is deprecated in favor of the Charset variant.

Also deprecate MustacheProperties.getCharsetName() as it's primarily
used with the deprecated setCharset(String) method.

This change maintains backward compatibility while providing a more
type-safe API that aligns with modern Java standards.

See spring-projectsgh-48347

Signed-off-by: djlee <ddongjunn@gmail.com>

snicoll pushed a commit to snicoll/spring-boot that referenced this pull request

Dec 1, 2025
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.

See spring-projectsgh-48347

Signed-off-by: djlee <ddongjunn@gmail.com>

snicoll added a commit to snicoll/spring-boot that referenced this pull request

Dec 1, 2025

philwebb

snicoll pushed a commit that referenced this pull request

Dec 19, 2025
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.

See gh-48347

Signed-off-by: djlee <ddongjunn@gmail.com>

snicoll added a commit that referenced this pull request

Dec 19, 2025
This replaces the use of charset name for our Mustache support.

See gh-48347