Skip to content

Commit 1a092b7

Browse files
committed
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
1 parent 804a65c commit 1a092b7

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

module/spring-boot-http-codec/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ dependencies {
3030

3131
optional(project(":core:spring-boot-autoconfigure"))
3232
optional(project(":core:spring-boot-test"))
33+
optional(project(":module:spring-boot-gson"))
3334
optional(project(":module:spring-boot-jackson"))
3435
optional(project(":module:spring-boot-jackson2"))
3536
optional(project(":module:spring-boot-kotlinx-serialization-json"))

module/spring-boot-http-codec/src/test/java/org/springframework/boot/http/codec/autoconfigure/CodecsAutoConfigurationTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.Map;
2121

2222
import com.fasterxml.jackson.databind.ObjectMapper;
23+
import com.google.gson.Gson;
2324
import kotlinx.serialization.json.Json;
2425
import org.junit.jupiter.api.Test;
2526
import tools.jackson.databind.json.JsonMapper;
@@ -150,7 +151,7 @@ void kotlinSerializationUsesLimitedPredicateWhenOtherJsonConverterIsAvailable()
150151
@Test
151152
void kotlinSerializationUsesUnrestrictedPredicateWhenNoOtherJsonConverterIsAvailable() {
152153
FilteredClassLoader classLoader = new FilteredClassLoader(JsonMapper.class.getPackage().getName(),
153-
ObjectMapper.class.getPackage().getName());
154+
ObjectMapper.class.getPackage().getName(), Gson.class.getPackage().getName());
154155
this.contextRunner.withClassLoader(classLoader)
155156
.withUserConfiguration(KotlinxJsonConfiguration.class)
156157
.run((context) -> {

0 commit comments

Comments
 (0)