Skip to content

Conversation

@ddongjunn
Copy link

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.

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>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 29, 2025
@philwebb
Copy link
Member

This would be a breaking change since MustacheResourceTemplateLoader.setCharset(String) is public API. I think we could add an overloaded method at some point and possibly also deprecate org.springframework.boot.mustache.autoconfigure.MustacheProperties.getCharsetName().

@philwebb philwebb added for: merge-with-amendments Needs some changes when we merge and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 29, 2025
@philwebb philwebb added this to the 4.1.x milestone Nov 29, 2025
@snicoll snicoll added the type: enhancement A general enhancement label Nov 30, 2025
@snicoll

This comment was marked as outdated.

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>
@ddongjunn
Copy link
Author

ddongjunn commented Dec 1, 2025

@philwebb Thanks for the feedback!

I’ve updated the PR to add the setCharset(Charset) overload while keeping the existing String-based method for backward compatibility (now deprecated).
I also deprecated MustacheProperties.getCharsetName() as suggested.

This keeps the change backward compatible while providing a more type-safe API.

Let me know if you’d like any further adjustments.

@snicoll snicoll removed the for: merge-with-amendments Needs some changes when we merge label Dec 1, 2025
@snicoll snicoll self-assigned this Dec 1, 2025
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
This replaces the use of charset name for our Mustache support.

See spring-projectsgh-48347
@snicoll
Copy link
Member

snicoll commented Dec 1, 2025

This PR is ready to be merged once main switches to 4.1.0-SNAPSHOT.

@ddongjunn thanks for the PR. To be consistent more work was required, see snicoll@65cd92f. When something is deprecated, our code base should not call it anymore. Then searching for the same pattern in the rest of the module for consistency revealed a number of other usages not covered initially. It's all done now and will be merged once we can.

@ddongjunn
Copy link
Author

@snicoll Thanks for reviewing and refining the PR.
I appreciate the consistency updates and the clear explanation.
Glad to hear it will be merged once 4.1.0-SNAPSHOT opens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants