-
Notifications
You must be signed in to change notification settings - Fork 640
Description
Describe the bug
When using multiple Kotlin function beans in a Spring Cloud Function setup, only one function gets registered. However, if the same logic is implemented using the Java Function interface, all functions are correctly registered.
Explicitly defining the return type in Kotlin does not resolve the issue.
Observed behavior
- Kotlin definition → Only one function is registered:
Registered Spring Cloud Functions: [routeConsentChanges, streamBridge, functionRouter] - Java definition → Both functions are registered correctly:
Registered Spring Cloud Functions: [routeConsentRepair, routeConsentChanges, streamBridge, functionRouter]
To Reproduce
The issue occurs when defining multiple functions using Kotlin lambda syntax.
Kotlin function definition (only one function is registered):
@Bean
fun routeConsentChanges(): (Message<ByteArray>) -> Message<Any>? = (
{ message -> messageMapper.remapMessage(message, log) })
@Bean
fun routeConsentRepair(): (Message<ByteArray>) -> Message<Any>? = (
{ message -> messageMapper.remapMessage(message, log) })Java function definition (both functions are correctly registered):
@Bean
fun routeConsentChanges(): Function<Message<ByteArray>, Message<Any>?> = Function { message ->
messageMapper.remapMessage(message, log)
}
@Bean
fun routeConsentRepair(): Function<Message<ByteArray>, Message<Any>?> = Function { message ->
messageMapper.remapMessage(message, log)
}Configuration (YAML) used in both cases:
function:
definition: routeConsentChanges;routeConsentRepairExpected behavior
Both Kotlin and Java function definitions should behave consistently, ensuring that all declared beans are properly registered.
Environment
- Spring Boot version:
3.4.3 - Spring Cloud version:
2024.0.0 - Spring Cloud Azure Starter version:
5.20.1 - Kotlin version:
2.1.10
Additional context
It appears that Spring Cloud Function does not correctly recognize multiple Kotlin function beans when using lambda syntax. Using the explicit Java Function interface resolves the issue, but this behavior is unexpected.
Let me know if you need additional details or a minimal reproducible example. 🚀