Skip to content

Commit e55a730

Browse files
committed
Upgrade to Gson 2.11.0
Closes gh-41407
1 parent b1586e6 commit e55a730

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/gson/GsonAutoConfiguration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import com.google.gson.Gson;
2222
import com.google.gson.GsonBuilder;
23+
import com.google.gson.Strictness;
2324

2425
import org.springframework.boot.autoconfigure.AutoConfiguration;
2526
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@@ -92,7 +93,7 @@ public void customize(GsonBuilder builder) {
9293
map.from(properties::getLongSerializationPolicy).to(builder::setLongSerializationPolicy);
9394
map.from(properties::getFieldNamingPolicy).to(builder::setFieldNamingPolicy);
9495
map.from(properties::getPrettyPrinting).whenTrue().toCall(builder::setPrettyPrinting);
95-
map.from(properties::getLenient).whenTrue().toCall(builder::setLenient);
96+
map.from(properties::getLenient).whenTrue().toCall(() -> builder.setStrictness(Strictness.LENIENT));
9697
map.from(properties::getDisableHtmlEscaping).whenTrue().toCall(builder::disableHtmlEscaping);
9798
map.from(properties::getDateFormat).to(builder::setDateFormat);
9899
}

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/gson/GsonAutoConfigurationTests.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.google.gson.Gson;
2929
import com.google.gson.GsonBuilder;
3030
import com.google.gson.LongSerializationPolicy;
31+
import com.google.gson.Strictness;
3132
import org.junit.jupiter.api.Test;
3233
import org.skyscreamer.jsonassert.JSONAssert;
3334

@@ -212,23 +213,23 @@ void withPrettyPrintingFalse() {
212213
void withoutLenient() {
213214
this.contextRunner.run((context) -> {
214215
Gson gson = context.getBean(Gson.class);
215-
assertThat(gson).hasFieldOrPropertyWithValue("lenient", false);
216+
assertThat(gson).hasFieldOrPropertyWithValue("strictness", null);
216217
});
217218
}
218219

219220
@Test
220221
void withLenientTrue() {
221222
this.contextRunner.withPropertyValues("spring.gson.lenient:true").run((context) -> {
222223
Gson gson = context.getBean(Gson.class);
223-
assertThat(gson).hasFieldOrPropertyWithValue("lenient", true);
224+
assertThat(gson).hasFieldOrPropertyWithValue("strictness", Strictness.LENIENT);
224225
});
225226
}
226227

227228
@Test
228229
void withLenientFalse() {
229230
this.contextRunner.withPropertyValues("spring.gson.lenient:false").run((context) -> {
230231
Gson gson = context.getBean(Gson.class);
231-
assertThat(gson).hasFieldOrPropertyWithValue("lenient", false);
232+
assertThat(gson).hasFieldOrPropertyWithValue("strictness", null);
232233
});
233234
}
234235

spring-boot-project/spring-boot-dependencies/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ bom {
471471
site("https://groovy-lang.org")
472472
}
473473
}
474-
library("Gson", "2.10.1") {
474+
library("Gson", "2.11.0") {
475475
group("com.google.code.gson") {
476476
modules = [
477477
"gson"

0 commit comments

Comments
 (0)