Skip to content

Commit 164115c

Browse files
committed
Add Charset overload for Mustache template encoding
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 gh-48347 Signed-off-by: djlee <ddongjunn@gmail.com>
1 parent e8030e5 commit 164115c

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ public Charset getCharset() {
124124
return this.charset;
125125
}
126126

127+
/**
128+
* Get the charset name.
129+
* @return the charset name
130+
* @deprecated since 4.1.0 in favor of {@link #getCharset()}
131+
*/
132+
@Deprecated(since = "4.1.0")
127133
public String getCharsetName() {
128134
return this.charset.name();
129135
}

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@ public MustacheResourceTemplateLoader(String prefix, String suffix) {
6262
/**
6363
* Set the charset.
6464
* @param charSet the charset
65+
* @deprecated since 4.1.0 in favor of {@link #setCharset(Charset)}
66+
*/
67+
@Deprecated(since = "4.1.0")
68+
public void setCharset(String charSet) {
69+
this.charSet = Charset.forName(charSet);
70+
}
71+
72+
/**
73+
* Set the charset.
74+
* @param charSet the charset
75+
* @since 4.1.0
6576
*/
6677
public void setCharset(Charset charSet) {
6778
this.charSet = charSet;

0 commit comments

Comments
 (0)