Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kelseyh opened this issue Dec 9, 2024 · 1 comment
Assignees
Milestone

Comments

@kelseyh
Copy link

kelseyh commented Dec 9, 2024

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

@olegz olegz self-assigned this Dec 9, 2024
@olegz olegz added the bug label Dec 9, 2024
@olegz olegz added this to the 4.2.1 milestone Dec 9, 2024
@olegz
Copy link
Contributor

olegz commented Dec 9, 2024

Yes indeed a regression after fixing #2974

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants