Handle Gson explicitly in CodecsAutoConfigurationTests

The change in gh-50447 added gson on the runtime classpath, which broke
a test that looks for "any" JSON support, but only filtered Jackson and
Jackson 2.

This commit adds an explicit optional dependency to gson and adapt the
test accordingly.

See gh-50447
This commit is contained in:
Stéphane Nicoll
2026-05-30 12:59:18 +02:00
parent 804a65cd6f
commit 1a092b779f
2 changed files with 3 additions and 1 deletions
@@ -30,6 +30,7 @@ dependencies {
optional(project(":core:spring-boot-autoconfigure"))
optional(project(":core:spring-boot-test"))
optional(project(":module:spring-boot-gson"))
optional(project(":module:spring-boot-jackson"))
optional(project(":module:spring-boot-jackson2"))
optional(project(":module:spring-boot-kotlinx-serialization-json"))
@@ -20,6 +20,7 @@ import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import kotlinx.serialization.json.Json;
import org.junit.jupiter.api.Test;
import tools.jackson.databind.json.JsonMapper;
@@ -150,7 +151,7 @@ class CodecsAutoConfigurationTests {
@Test
void kotlinSerializationUsesUnrestrictedPredicateWhenNoOtherJsonConverterIsAvailable() {
FilteredClassLoader classLoader = new FilteredClassLoader(JsonMapper.class.getPackage().getName(),
ObjectMapper.class.getPackage().getName());
ObjectMapper.class.getPackage().getName(), Gson.class.getPackage().getName());
this.contextRunner.withClassLoader(classLoader)
.withUserConfiguration(KotlinxJsonConfiguration.class)
.run((context) -> {