Upgrade to Gson 2.11.0

Closes gh-41407
This commit is contained in:
Andy Wilkinson 2024-07-09 13:05:05 +01:00
parent b1586e693b
commit e55a730ea0
3 changed files with 7 additions and 5 deletions

View File

@ -20,6 +20,7 @@ import java.util.List;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import com.google.gson.Strictness;
import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@ -92,7 +93,7 @@ public class GsonAutoConfiguration {
map.from(properties::getLongSerializationPolicy).to(builder::setLongSerializationPolicy); map.from(properties::getLongSerializationPolicy).to(builder::setLongSerializationPolicy);
map.from(properties::getFieldNamingPolicy).to(builder::setFieldNamingPolicy); map.from(properties::getFieldNamingPolicy).to(builder::setFieldNamingPolicy);
map.from(properties::getPrettyPrinting).whenTrue().toCall(builder::setPrettyPrinting); 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::getDisableHtmlEscaping).whenTrue().toCall(builder::disableHtmlEscaping);
map.from(properties::getDateFormat).to(builder::setDateFormat); map.from(properties::getDateFormat).to(builder::setDateFormat);
} }

View File

@ -28,6 +28,7 @@ import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import com.google.gson.LongSerializationPolicy; import com.google.gson.LongSerializationPolicy;
import com.google.gson.Strictness;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.skyscreamer.jsonassert.JSONAssert; import org.skyscreamer.jsonassert.JSONAssert;
@ -212,7 +213,7 @@ class GsonAutoConfigurationTests {
void withoutLenient() { void withoutLenient() {
this.contextRunner.run((context) -> { this.contextRunner.run((context) -> {
Gson gson = context.getBean(Gson.class); Gson gson = context.getBean(Gson.class);
assertThat(gson).hasFieldOrPropertyWithValue("lenient", false); assertThat(gson).hasFieldOrPropertyWithValue("strictness", null);
}); });
} }
@ -220,7 +221,7 @@ class GsonAutoConfigurationTests {
void withLenientTrue() { void withLenientTrue() {
this.contextRunner.withPropertyValues("spring.gson.lenient:true").run((context) -> { this.contextRunner.withPropertyValues("spring.gson.lenient:true").run((context) -> {
Gson gson = context.getBean(Gson.class); 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() { void withLenientFalse() {
this.contextRunner.withPropertyValues("spring.gson.lenient:false").run((context) -> { this.contextRunner.withPropertyValues("spring.gson.lenient:false").run((context) -> {
Gson gson = context.getBean(Gson.class); Gson gson = context.getBean(Gson.class);
assertThat(gson).hasFieldOrPropertyWithValue("lenient", false); assertThat(gson).hasFieldOrPropertyWithValue("strictness", null);
}); });
} }

View File

@ -471,7 +471,7 @@ bom {
site("https://groovy-lang.org") site("https://groovy-lang.org")
} }
} }
library("Gson", "2.10.1") { library("Gson", "2.11.0") {
group("com.google.code.gson") { group("com.google.code.gson") {
modules = [ modules = [
"gson" "gson"