From e8030e5eb57cecec3de332b9676deee33a4381ab Mon Sep 17 00:00:00 2001 From: djlee Date: Sun, 30 Nov 2025 00:35:02 +0900 Subject: [PATCH 1/2] 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: djlee --- .../autoconfigure/MustacheResourceTemplateLoader.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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..9767d5b00093 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); @@ -61,7 +63,7 @@ public MustacheResourceTemplateLoader(String prefix, String suffix) { * Set the charset. * @param charSet the charset */ - public void setCharset(String charSet) { + public void setCharset(Charset charSet) { this.charSet = charSet; } From 4e3cdc3264e6367399e015e7d4c33c0850bcfac3 Mon Sep 17 00:00:00 2001 From: djlee Date: Sun, 30 Nov 2025 01:06:38 +0900 Subject: [PATCH 2/2] Simplify Property handling using map().getOrNull() This change improves the readability and idiomatic use of Gradle's `Property` API by replacing an explicit `isPresent()` check with `map(...).getOrNull()`. The new version is functionally equivalent but more concise and aligns with recommended usage patterns in Gradle property handling. No behavioral changes. Signed-off-by: djlee --- .../boot/gradle/tasks/bundling/BootArchiveSupport.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-plugin/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootArchiveSupport.java b/build-plugin/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootArchiveSupport.java index 12b68384e91f..647b36181bbf 100644 --- a/build-plugin/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootArchiveSupport.java +++ b/build-plugin/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootArchiveSupport.java @@ -147,7 +147,7 @@ CopyAction createCopyAction(Jar jar, ResolvedDependencies resolvedDependencies, } private @Nullable Integer asUnixNumeric(Property permissions) { - return permissions.isPresent() ? permissions.get().toUnixNumeric() : null; + return permissions.map(ConfigurableFilePermissions::toUnixNumeric).getOrNull(); } private @Nullable Integer getDirMode(CopySpec copySpec) {