-
Notifications
You must be signed in to change notification settings - Fork 630
Description
Describe the issue
We upgraded our application to spring-cloud version 2025.0.1 (spring-cloud-stream v4.3.1) from 2025.0.0 (spring-cloud-stream v4.3.0).
Our application fails to start.
The application uses org.springframework.cloud:spring-cloud-starter-bootstrap .
RoutingFunctionEnvironmentPostProcessor throws
java.lang.ClassCastException: class org.springframework.cloud.bootstrap.BootstrapApplicationListener$1 cannot be cast to class org.springframework.core.env.StandardEnvironment
To Reproduce
Steps to reproduce the behavior:
- Upgrade spring-cloud to version 2025.0.1
- Add org.springframework.cloud:spring-cloud-starter-bootstrap in the classpath
- Use org.springframework.cloud:spring-cloud-stream-binder-kafka
- See error
Version of the framework
spring-cloud version 2025.0.1
Expected behavior
application should start without exception
Additional context
In version 4.3.0
RoutingFunctionEnvironmentPostProcessor has the following method:
@Override
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
String name = environment.getProperty("spring.cloud.function.definition");
if (StringUtils.hasText(name) && (
name.equals(RoutingFunction.FUNCTION_NAME) ||
name.contains(RoutingFunction.FUNCTION_NAME + "|") ||
name.contains("|" + RoutingFunction.FUNCTION_NAME)
)) {
((StandardEnvironment) environment).getSystemProperties()
.putIfAbsent("spring.cloud.function.routing.enabled", "true");
}
}
(StandardEnvironment) environment casting is only done when environment.getProperty("spring.cloud.function.definition") has text.
In version 4.3.1
RoutingFunctionEnvironmentPostProcessor has the following method:
@Override
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
String name = environment.getProperty("spring.cloud.function.definition");
if (StringUtils.hasText(name) && (
name.equals(RoutingFunction.FUNCTION_NAME) ||
name.contains(RoutingFunction.FUNCTION_NAME + "|") ||
name.contains("|" + RoutingFunction.FUNCTION_NAME)
)) {
((StandardEnvironment) environment).getSystemProperties()
.putIfAbsent("spring.cloud.function.routing.enabled", "true");
}
// perhaps mpve it to separate class as it doesn't have much to do with RoutingFunction
((StandardEnvironment) environment).getSystemProperties()
.putIfAbsent("spring.cloud.function.configuration.default.copy-input-headers", "true");
}
The casting is done even if environment.getProperty("spring.cloud.function.definition") has no text.