Skip to content

Commit

Permalink
Merge branch 'master' into fix/javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbakker authored Jan 9, 2025
2 parents 288e7fe + 04fb147 commit f4cc308
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,13 @@ class ExcludeAutoConfigurationsEnvironmentPostProcessor : EnvironmentPostProcess
)
}

private fun extractAllExcludes(propertySources: MutablePropertySources): String =
propertySources
private fun extractAllExcludes(propertySources: MutablePropertySources): String {
val testExclude = propertySources.find { it.name == INLINED_TEST_PROPERTIES }?.getProperty(EXCLUDE)
if (testExclude != null && testExclude is String && testExclude.isNotBlank()) {
return testExclude
}

return propertySources
.stream()
.filter { src -> !ConfigurationPropertySources.isAttachedConfigurationPropertySource(src) }
.map { src ->
Expand All @@ -71,6 +76,7 @@ class ExcludeAutoConfigurationsEnvironmentPostProcessor : EnvironmentPostProcess
}.orElse(emptyList())
}.flatMap { it.stream() }
.collect(Collectors.joining(","))
}

companion object {
private val DISABLE_AUTOCONFIG_PROPERTIES =
Expand All @@ -86,5 +92,6 @@ class ExcludeAutoConfigurationsEnvironmentPostProcessor : EnvironmentPostProcess
)

private const val EXCLUDE = "spring.autoconfigure.exclude"
private const val INLINED_TEST_PROPERTIES = "Inlined Test Properties"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,24 @@ class ExcludeAutoConfigurationsEnvironmentPostProcessorTest {
"org.springframework.boot.autoconfigure.graphql.security.GraphQlWebMvcSecurityAutoConfiguration",
)
}

@Test
fun `does not reintroduce overridden excludes in test properties`() {
val env = StandardEnvironment()
env.propertySources.addLast(MapPropertySource("application-props", mapOf(Pair("spring.autoconfigure.exclude", "someexclude"))))
env.propertySources.addLast(
MapPropertySource("Inlined Test Properties", mapOf(Pair("spring.autoconfigure.exclude", "someotherexclude"))),
)

ExcludeAutoConfigurationsEnvironmentPostProcessor().postProcessEnvironment(env, SpringApplication())
assertThat(env.getProperty("spring.autoconfigure.exclude"))
.contains(
"someotherexclude",
"org.springframework.boot.actuate.autoconfigure.observation.graphql.GraphQlObservationAutoConfiguration",
"org.springframework.boot.autoconfigure.graphql.security.GraphQlWebMvcSecurityAutoConfiguration",
)

assertThat(env.getProperty("spring.autoconfigure.exclude"))
.doesNotContain("someexclude")
}
}

0 comments on commit f4cc308

Please sign in to comment.