Hello!

Our project is currently trying to register a custom bootstrap property source that will load properties into our application environment at the bootstrap phase. This has worked great for us.

However, we've recently been trying to register a non-enumerable property source but keep receiving the following error; I believe there is an issue that makes it not possible to register non-enumerable property sources as bootstrap properties.

Reproduction is here: https://github.com/dzou/non-enumerable-prop-source-ex

Error message:

***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to bind properties under 'spring.cloud.config' to org.springframework.cloud.bootstrap.config.PropertySourceBootstrapProperties:

    Property: spring.cloud.config
    Value: constant-property
    Origin: "spring.cloud.config" from property source "bootstrapProperties-My-Custom-Bootstrap-Property-Source"
    Reason: Failed to enumerate property names due to non-enumerable property source: CustomPropertySource {name='My-Custom-Bootstrap-Property-Source'}

Action:

Update your application's configuration

I traced the issue through the code, I think I know where the source of the issue is.

Basically there are a few interactions:

  1. All Bootstrap property sources are initialized and then wrapped in the BootstrapPropertySource class in this line.

  2. The BootstrapPropertySource class extends from EnumerablePropertySource.

  3. Then, when all the property sources are checked for whether they are enumerable or not, the framework believes it is enumerable because later the code checks for whether the property source is instance of EnumerablePropertySource.

    This is not quite right because in the case of the BootstrapPropertySource it should instead check if the delegate is instanceof EnumerablePropertySource instead of the property source itself.

Let me know your thoughts on this! We were excited to discover bootstrap properties and very excited to see if it can work for non-enumerable property sources.

Comment From: mbhave

@dzou Thanks for getting in touch but bootstrap properties is a Spring Cloud feature. Please create an issue in the Spring Cloud issue tracker.