Skip to content

No converter found capable of converting from type [java.lang.String] to type [org.springframework.expression.Expression] #3053

@kelseyh

Description

@kelseyh

Describe the issue
Upgrading from spring-cloud-stream 2023.0.3 to 2023.0.4 results in the following error:

Failed to bind properties under 'spring.cloud.stream.kafka.default.producer.message-key-expression' to org.springframework.expression.Expression:

    Property: spring.cloud.stream.kafka.default.producer.message-key-expression
    Value: "headers['id']"
    Origin: class path resource [application.yml] - 5:48
    Reason: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [org.springframework.expression.Expression]

This looks like a regression bug that was previously reported in #2283

To Reproduce

  1. Generate a new project from https://start.spring.io/index.html (spring-boot: 3.3.6, spring-cloud: 2023.0.4)
  2. Add the kafka binder
<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-stream-binder-kafka</artifactId>
</dependency>
  1. use the following application.yml
spring:
  application.name: demo
  cloud:
    stream:
      kafka:
        default.producer.message-key-expression: headers['id']
        binder:
          brokers: localhost:9092
      bindings:
        test-out-0:
          destination: out
        test-in-0:
          destination: in
          group: test

Add a consumer in the Application.class

	@Bean
	public Consumer<Message<String>> test() {
		return message -> System.out.println("Received message: " + message);
	}
  1. run mvn spring-boot:run
  2. Error will be printed out in the logs.

Version of the framework
2023.0.4
Expected behavior
Should convert the expression as it does in 2023.0.3

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions