Skip to content

Commit f4cc308

Browse files
authored
Merge branch 'master' into fix/javadoc
2 parents 288e7fe + 04fb147 commit f4cc308

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

graphql-dgs-spring-graphql/src/main/kotlin/com/netflix/graphql/dgs/springgraphql/autoconfig/ExcludeAutoConfigurationsEnvironmentPostProcessor.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,13 @@ class ExcludeAutoConfigurationsEnvironmentPostProcessor : EnvironmentPostProcess
5959
)
6060
}
6161

62-
private fun extractAllExcludes(propertySources: MutablePropertySources): String =
63-
propertySources
62+
private fun extractAllExcludes(propertySources: MutablePropertySources): String {
63+
val testExclude = propertySources.find { it.name == INLINED_TEST_PROPERTIES }?.getProperty(EXCLUDE)
64+
if (testExclude != null && testExclude is String && testExclude.isNotBlank()) {
65+
return testExclude
66+
}
67+
68+
return propertySources
6469
.stream()
6570
.filter { src -> !ConfigurationPropertySources.isAttachedConfigurationPropertySource(src) }
6671
.map { src ->
@@ -71,6 +76,7 @@ class ExcludeAutoConfigurationsEnvironmentPostProcessor : EnvironmentPostProcess
7176
}.orElse(emptyList())
7277
}.flatMap { it.stream() }
7378
.collect(Collectors.joining(","))
79+
}
7480

7581
companion object {
7682
private val DISABLE_AUTOCONFIG_PROPERTIES =
@@ -86,5 +92,6 @@ class ExcludeAutoConfigurationsEnvironmentPostProcessor : EnvironmentPostProcess
8692
)
8793

8894
private const val EXCLUDE = "spring.autoconfigure.exclude"
95+
private const val INLINED_TEST_PROPERTIES = "Inlined Test Properties"
8996
}
9097
}

graphql-dgs-spring-graphql/src/test/kotlin/com/netflix/graphql/dgs/springgraphql/autoconfig/ExcludeAutoConfigurationsEnvironmentPostProcessorTest.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,24 @@ class ExcludeAutoConfigurationsEnvironmentPostProcessorTest {
6161
"org.springframework.boot.autoconfigure.graphql.security.GraphQlWebMvcSecurityAutoConfiguration",
6262
)
6363
}
64+
65+
@Test
66+
fun `does not reintroduce overridden excludes in test properties`() {
67+
val env = StandardEnvironment()
68+
env.propertySources.addLast(MapPropertySource("application-props", mapOf(Pair("spring.autoconfigure.exclude", "someexclude"))))
69+
env.propertySources.addLast(
70+
MapPropertySource("Inlined Test Properties", mapOf(Pair("spring.autoconfigure.exclude", "someotherexclude"))),
71+
)
72+
73+
ExcludeAutoConfigurationsEnvironmentPostProcessor().postProcessEnvironment(env, SpringApplication())
74+
assertThat(env.getProperty("spring.autoconfigure.exclude"))
75+
.contains(
76+
"someotherexclude",
77+
"org.springframework.boot.actuate.autoconfigure.observation.graphql.GraphQlObservationAutoConfiguration",
78+
"org.springframework.boot.autoconfigure.graphql.security.GraphQlWebMvcSecurityAutoConfiguration",
79+
)
80+
81+
assertThat(env.getProperty("spring.autoconfigure.exclude"))
82+
.doesNotContain("someexclude")
83+
}
6484
}

0 commit comments

Comments
 (0)