diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/gson/GsonAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/gson/GsonAutoConfiguration.java index 94ed69c7451..d61e9a270e7 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/gson/GsonAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/gson/GsonAutoConfiguration.java @@ -20,6 +20,7 @@ import java.util.List; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.Strictness; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -92,7 +93,7 @@ public class GsonAutoConfiguration { map.from(properties::getLongSerializationPolicy).to(builder::setLongSerializationPolicy); map.from(properties::getFieldNamingPolicy).to(builder::setFieldNamingPolicy); map.from(properties::getPrettyPrinting).whenTrue().toCall(builder::setPrettyPrinting); - map.from(properties::getLenient).whenTrue().toCall(builder::setLenient); + map.from(properties::getLenient).whenTrue().toCall(() -> builder.setStrictness(Strictness.LENIENT)); map.from(properties::getDisableHtmlEscaping).whenTrue().toCall(builder::disableHtmlEscaping); map.from(properties::getDateFormat).to(builder::setDateFormat); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/gson/GsonAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/gson/GsonAutoConfigurationTests.java index 179280d8d18..7481a5b5282 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/gson/GsonAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/gson/GsonAutoConfigurationTests.java @@ -28,6 +28,7 @@ import com.google.gson.FieldNamingPolicy; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.LongSerializationPolicy; +import com.google.gson.Strictness; import org.junit.jupiter.api.Test; import org.skyscreamer.jsonassert.JSONAssert; @@ -212,7 +213,7 @@ class GsonAutoConfigurationTests { void withoutLenient() { this.contextRunner.run((context) -> { Gson gson = context.getBean(Gson.class); - assertThat(gson).hasFieldOrPropertyWithValue("lenient", false); + assertThat(gson).hasFieldOrPropertyWithValue("strictness", null); }); } @@ -220,7 +221,7 @@ class GsonAutoConfigurationTests { void withLenientTrue() { this.contextRunner.withPropertyValues("spring.gson.lenient:true").run((context) -> { Gson gson = context.getBean(Gson.class); - assertThat(gson).hasFieldOrPropertyWithValue("lenient", true); + assertThat(gson).hasFieldOrPropertyWithValue("strictness", Strictness.LENIENT); }); } @@ -228,7 +229,7 @@ class GsonAutoConfigurationTests { void withLenientFalse() { this.contextRunner.withPropertyValues("spring.gson.lenient:false").run((context) -> { Gson gson = context.getBean(Gson.class); - assertThat(gson).hasFieldOrPropertyWithValue("lenient", false); + assertThat(gson).hasFieldOrPropertyWithValue("strictness", null); }); } diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index dde4a487fdc..7800837a847 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -471,7 +471,7 @@ bom { site("https://groovy-lang.org") } } - library("Gson", "2.10.1") { + library("Gson", "2.11.0") { group("com.google.code.gson") { modules = [ "gson"