Skip to content

Commit

Permalink
If a spring.autoconfigure.exclude property is defined in a test prope…
Browse files Browse the repository at this point in the history
…rty source, don't undo the override in the ExcludeAutoConfigurationsEnvironmentPostProcessor
  • Loading branch information
paulbakker committed Jan 7, 2025
1 parent a300767 commit a2b0c41
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,15 @@ class ExcludeAutoConfigurationsEnvironmentPostProcessor : EnvironmentPostProcess
)
}

private fun extractAllExcludes(propertySources: MutablePropertySources): String =
propertySources
private fun extractAllExcludes(propertySources: MutablePropertySources): String {
if(propertySources.any { it.name == "Inlined Test Properties" }) {
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 +78,8 @@ class ExcludeAutoConfigurationsEnvironmentPostProcessor : EnvironmentPostProcess
}.orElse(emptyList())
}.flatMap { it.stream() }
.collect(Collectors.joining(","))
}


companion object {
private val DISABLE_AUTOCONFIG_PROPERTIES =
Expand Down

0 comments on commit a2b0c41

Please sign in to comment.