From e27009d185df45845012a183b2eeed578fa3b1d2 Mon Sep 17 00:00:00 2001 From: Moritz Halbritter Date: Wed, 6 Aug 2025 10:29:36 +0200 Subject: [PATCH] Add nullability annotations to module/spring-boot-thymeleaf See gh-46587 --- .../autoconfigure/ThymeleafProperties.java | 38 ++++++++++--------- .../thymeleaf/autoconfigure/package-info.java | 3 ++ 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/module/spring-boot-thymeleaf/src/main/java/org/springframework/boot/thymeleaf/autoconfigure/ThymeleafProperties.java b/module/spring-boot-thymeleaf/src/main/java/org/springframework/boot/thymeleaf/autoconfigure/ThymeleafProperties.java index 46481963d40..dd2ac94faa2 100644 --- a/module/spring-boot-thymeleaf/src/main/java/org/springframework/boot/thymeleaf/autoconfigure/ThymeleafProperties.java +++ b/module/spring-boot-thymeleaf/src/main/java/org/springframework/boot/thymeleaf/autoconfigure/ThymeleafProperties.java @@ -20,6 +20,8 @@ import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.List; +import org.jspecify.annotations.Nullable; + import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.http.MediaType; import org.springframework.util.MimeType; @@ -83,17 +85,17 @@ public class ThymeleafProperties { * first in the chain. Order start at 1 and should only be set if you have defined * additional "TemplateResolver" beans. */ - private Integer templateResolverOrder; + private @Nullable Integer templateResolverOrder; /** * List of view names (patterns allowed) that can be resolved. */ - private String[] viewNames; + private String @Nullable [] viewNames; /** * List of view names (patterns allowed) that should be excluded from resolution. */ - private String[] excludedViewNames; + private String @Nullable [] excludedViewNames; /** * Enable the SpringEL compiler in SpringEL expressions. @@ -179,27 +181,27 @@ public class ThymeleafProperties { this.cache = cache; } - public Integer getTemplateResolverOrder() { + public @Nullable Integer getTemplateResolverOrder() { return this.templateResolverOrder; } - public void setTemplateResolverOrder(Integer templateResolverOrder) { + public void setTemplateResolverOrder(@Nullable Integer templateResolverOrder) { this.templateResolverOrder = templateResolverOrder; } - public String[] getExcludedViewNames() { + public String @Nullable [] getExcludedViewNames() { return this.excludedViewNames; } - public void setExcludedViewNames(String[] excludedViewNames) { + public void setExcludedViewNames(String @Nullable [] excludedViewNames) { this.excludedViewNames = excludedViewNames; } - public String[] getViewNames() { + public String @Nullable [] getViewNames() { return this.viewNames; } - public void setViewNames(String[] viewNames) { + public void setViewNames(String @Nullable [] viewNames) { this.viewNames = viewNames; } @@ -269,25 +271,25 @@ public class ThymeleafProperties { /** * Media types supported by the view technology. */ - private List mediaTypes; + private @Nullable List mediaTypes; /** * Comma-separated list of view names (patterns allowed) that should be executed * in FULL mode even if a max chunk size is set. */ - private String[] fullModeViewNames; + private String @Nullable [] fullModeViewNames; /** * Comma-separated list of view names (patterns allowed) that should be the only * ones executed in CHUNKED mode when a max chunk size is set. */ - private String[] chunkedModeViewNames; + private String @Nullable [] chunkedModeViewNames; - public List getMediaTypes() { + public @Nullable List getMediaTypes() { return this.mediaTypes; } - public void setMediaTypes(List mediaTypes) { + public void setMediaTypes(@Nullable List mediaTypes) { this.mediaTypes = mediaTypes; } @@ -299,19 +301,19 @@ public class ThymeleafProperties { this.maxChunkSize = maxChunkSize; } - public String[] getFullModeViewNames() { + public String @Nullable [] getFullModeViewNames() { return this.fullModeViewNames; } - public void setFullModeViewNames(String[] fullModeViewNames) { + public void setFullModeViewNames(String @Nullable [] fullModeViewNames) { this.fullModeViewNames = fullModeViewNames; } - public String[] getChunkedModeViewNames() { + public String @Nullable [] getChunkedModeViewNames() { return this.chunkedModeViewNames; } - public void setChunkedModeViewNames(String[] chunkedModeViewNames) { + public void setChunkedModeViewNames(String @Nullable [] chunkedModeViewNames) { this.chunkedModeViewNames = chunkedModeViewNames; } diff --git a/module/spring-boot-thymeleaf/src/main/java/org/springframework/boot/thymeleaf/autoconfigure/package-info.java b/module/spring-boot-thymeleaf/src/main/java/org/springframework/boot/thymeleaf/autoconfigure/package-info.java index 947b5e4b5b3..43792f9383c 100644 --- a/module/spring-boot-thymeleaf/src/main/java/org/springframework/boot/thymeleaf/autoconfigure/package-info.java +++ b/module/spring-boot-thymeleaf/src/main/java/org/springframework/boot/thymeleaf/autoconfigure/package-info.java @@ -17,4 +17,7 @@ /** * Auto-configuration for Thymeleaf. */ +@NullMarked package org.springframework.boot.thymeleaf.autoconfigure; + +import org.jspecify.annotations.NullMarked;