Describe the issue
When the config has a SpEL expression which looks like a boolean or number (i.e. things that YAML doesn't automatically treat as a string), then applications will fail to startup with:
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to bind properties under 'spring.cloud.stream.bindings.<binding-name>.producer.partition-key-expression' to org.springframework.expression.Expression:
Property: spring.cloud.stream.bindings.producer.partition-key-expression
Value: "true"
Origin: class path resource [application.yml] - 84:18
Reason: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.Boolean] to type [org.springframework.expression.Expression]
To Reproduce
Steps to reproduce the behavior:
- Use any config property declared with the type
Expression, such as spring.cloud.stream.bindings.<binding-name>.producer.partition-key-expression.
- Note: I'm using a yaml file for my config when I tested this.
- Using
partition-key-expression here just as a way to illustrate the problem. We're not actually using partition-key-expression to set number or boolean values, but a custom config property declared in the same way.
- Set this config property with a boolean-like or number-like value, such as
true or 5. e.g.:
spring:
cloud:
stream:
bindings:
<binding-name>:
producer:
partition-key-expression: 5 # must not be quoted in ""
- Start app
- See error
Version of the framework
Spring boot: 3.3.2
Spring Cloud: 2023.0.3
Expected behavior
All values passed to expression-typed config options should automatically be treated as strings when converting them to Expressions.
My guess is that SpelConverter either needs to be updated to handle boolean and number types, or delegate to the ConversionService to convert any arbitrary value to a String before converting it to an Expression.
Describe the issue
When the config has a SpEL expression which looks like a boolean or number (i.e. things that YAML doesn't automatically treat as a string), then applications will fail to startup with:
To Reproduce
Steps to reproduce the behavior:
Expression, such asspring.cloud.stream.bindings.<binding-name>.producer.partition-key-expression.partition-key-expressionhere just as a way to illustrate the problem. We're not actually usingpartition-key-expressionto set number or boolean values, but a custom config property declared in the same way.trueor5. e.g.:Version of the framework
Spring boot: 3.3.2
Spring Cloud: 2023.0.3
Expected behavior
All values passed to expression-typed config options should automatically be treated as strings when converting them to
Expressions.My guess is that SpelConverter either needs to be updated to handle boolean and number types, or delegate to the
ConversionServiceto convert any arbitrary value to aStringbefore converting it to anExpression.