Skip to content

Inconsistent behavior of Environment binding properties in SCS parent-child contexts #3039

@moarychan

Description

@moarychan

The Environment instance in the SCS parent and child contexts are ApplicationServletEnvironment and SystemEnvironmentPropertySource respectively, which causes the property values ​​they obtain to be inconsistent with expectations, for example: for a property spring.cloud.azure.eventhubs.connection-string, if configuring SPRING_CLOUD_AZURE_EVENTHUBS_CONNECTIONSTRING, then it cannot be got by env in sub context, see the logic from checkPropertyName
Describe the issue
I can see the parent context using SystemEnvironmentPropertyMapper to map candidate to find the property value; but the sub context does not leverage the mapper,
scs-binding-props

To Reproduce
Steps to reproduce the behavior:

  1. Base on Kafka binder usage, registry a configuration for sub context, such as spring.cloud.stream.binders.kafka.environment.spring.main.sources=com.reproducer.MyConfig
  2. Define a connectionString bean with the condition @ConditionalOnProperty("a.b.connection-string")
  3. Configure an environment variable, A_B__CONNECTIONSTRING=connection-string-value
  4. Run the app, the connectionString bean is not registered into sub context.

Version of the framework Spring Boot 3.3.5 & Spring Cloud Stream 4.1.3
Expected behavior To get same candidates against SystemEnvironmentPropertyMapper mapped.
Screenshots
image

Additional context
N/A

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions