[go: nahoru, domu]

Skip to content
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

Refine KotlinDetector.isKotlinType documentation for Kotlin 2.x lambdas #32905

Closed
antechrestos opened this issue May 27, 2024 · 6 comments
Closed
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) theme: kotlin An issue related to Kotlin support type: documentation A documentation task
Milestone

Comments

@antechrestos
Copy link

Using the spring cloud stream with reactive used to work well by instanciating kotlin function as follows

@Configuration(proxyBeanMethods = false)
class MessageConfiguration {

   @Bean
   fun myMessageConsumer() = { rawMessagesFlux ->
            rawMessagesFlux
                .flatMap { // ... }
                .then()
   }

Moving to kotlin 2.0 fails as generated bean class returns false when passing it to KotlinDetector.isKotlinType. Hence starting of spring cloud stream module fails as KotlinFunctionWrapper is not put and the Configuration expects java Function, Consumer or Supplier ...

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label May 27, 2024
@bclozel bclozel transferred this issue from spring-projects/spring-boot May 27, 2024
@bclozel bclozel added in: core Issues in core modules (aop, beans, core, context, expression) theme: kotlin An issue related to Kotlin support labels May 27, 2024
@sdeleuze
Copy link
Contributor

@antechrestos Can you please provide a reproducer as an attached project or a link to a repository?

@sdeleuze sdeleuze added the status: waiting-for-feedback We need additional information before we can continue label May 27, 2024
@antechrestos
Copy link
Author

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels May 28, 2024
@sdeleuze
Copy link
Contributor
sdeleuze commented May 28, 2024

I confirm this change of behavior caused by the fact that generation of lambda functions using invokedynamic is now the default, and I don't think we can do something about it at Spring Framework level except in terms of documentation so I turn it into a documentation issue.

FYI SAM-converted lambda like HelloHandler { ... } were already generated via invokedynamic as of Kotlin 1.5, for non regular lambda { ... } that new in Kotlin 2.0, and @JvmSerializableLambda can be used as a workaround (fun helloConsumer(helloHandler: HelloHandler): (Flux<Message<ByteArray>>) -> Mono<Void> = @JvmSerializableLambda { ...).

@antechrestos Could you please create a related issue in Spring Cloud Function linking the repro in order to allow @olegz and @sobychacko to review how BeanFactoryAwareFunctionRegistry (sources) logic could be changed?

@sdeleuze sdeleuze changed the title KotlinDetector.isKotlinType fails with Bean kotlin 2.0 Function Refine KotlinDetector.isKotlinType documentation for Kotlin 2.x lambdas May 28, 2024
@sdeleuze sdeleuze added type: documentation A documentation task and removed status: waiting-for-triage An issue we've not yet triaged or decided on status: feedback-provided Feedback has been provided labels May 28, 2024
@sdeleuze sdeleuze added this to the 6.1.9 milestone May 28, 2024
@antechrestos
Copy link
Author

done

@antechrestos
Copy link
Author

I confirm that the workaround using@JvmSerializableLambda makes the trick.

@sdeleuze do you want me to close this PR and let the PR on cloud-function repository be the reference?

@sdeleuze
Copy link
Contributor
sdeleuze commented Jun 3, 2024

@antechrestos if I am not mistaken, this is an issue not a PR and I have repurposed it to refine the documentation, so please keep it opened, I will close it with a related commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) theme: kotlin An issue related to Kotlin support type: documentation A documentation task
Projects
None yet
Development

No branches or pull requests

4 participants