-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Kotlin DSL: handle(handler: (P, MessageHeaders) -> Any) endpoint should not require output channel if lambda returns void #3344
Comments
Well, since your lambda doesn't return anything (because of For now it looks like we need to treat that If there are better ideas how to make this Kotlin stuff working, I'm fully open for suggestion. Thanks. |
For more Kotlin background: https://medium.com/thoughts-overflow/kotlin-has-nothing-but-there-is-nothing-like-nothing-in-java-cab98e4f4d26 |
Fixes spring-projects#3344 When function lambda doesn't return anything (e.g. a `void` method call is the last one), Kotlin produces a `kotlin.Unit` instance as a return value which is not null and produced as a reply message payload. * Fix `MessagingMethodInvokerHelper` to treat a `kotlin.Unit` as `null` for reply making Kotlin lambdas working the same way as Java lambdas when we don't return anything from from there **Cherry-pick to `5.3.x`**
See PR on the matter: #3346 |
@artembilan I think you nailed it. Another possible idea I have is to add to DSL |
True. |
* GH-3344: Treat kotlin.Unit return as null in MMIH Fixes #3344 When function lambda doesn't return anything (e.g. a `void` method call is the last one), Kotlin produces a `kotlin.Unit` instance as a return value which is not null and produced as a reply message payload. * Fix `MessagingMethodInvokerHelper` to treat a `kotlin.Unit` as `null` for reply making Kotlin lambdas working the same way as Java lambdas when we don't return anything from from there **Cherry-pick to `5.3.x`** * * Introduce `ClassUtils.isKotlinUnit(Class)` API; use it in the `MessagingMethodInvokerHelper` instead of `.getName().equals()` * * Fix since on new `isKotlinUnit()` API
* GH-3344: Treat kotlin.Unit return as null in MMIH Fixes #3344 When function lambda doesn't return anything (e.g. a `void` method call is the last one), Kotlin produces a `kotlin.Unit` instance as a return value which is not null and produced as a reply message payload. * Fix `MessagingMethodInvokerHelper` to treat a `kotlin.Unit` as `null` for reply making Kotlin lambdas working the same way as Java lambdas when we don't return anything from from there **Cherry-pick to `5.3.x`** * * Introduce `ClassUtils.isKotlinUnit(Class)` API; use it in the `MessagingMethodInvokerHelper` instead of `.getName().equals()` * * Fix since on new `isKotlinUnit()` API
Expected Behavior
handle<T> { payload, headers -> .. }
should work without output channel configured if lambda returnsvoid
.Like
handle { message -> .. }
currently does.Current Behavior
throws
DestinationResolutionException: no output-channel or replyChannel header available
. Whileworks as intended.
Context
Now I am using this workaround, not sure if it is the best way to go:
The text was updated successfully, but these errors were encountered: