Affects: 5.2.0.RC1+
2c33c11 / #23250 added the new TransactionOperations.execute(Runnable) method for Java lambda usage without return value.
However it breaks existing Kotlin code using TransactionTemplate with return values:
val result = transactionTemplate.execute {
...
1
}
// result becomes Unit type, which used to be Int? type
This happens because Kotlin allows omitting single parameter (the implicit it parameter). Kotlin compiler cannot distinguish no-arg Runnable with unary TransactionCallback<T>.
In order to disambiguate, a parameter or the callback interface should be explicitly stated:
val result = transactionTemplate.execute { _ ->
...
1
}
// or
val result = transactionTemplate.execute(TransactionCallback {
...
1
})
I'm not sure how to fix it. Maybe let it break for bigger convenience in Java?
Affects: 5.2.0.RC1+
2c33c11 / #23250 added the new
TransactionOperations.execute(Runnable)method for Java lambda usage without return value.However it breaks existing Kotlin code using TransactionTemplate with return values:
This happens because Kotlin allows omitting single parameter (the implicit
itparameter). Kotlin compiler cannot distinguish no-argRunnablewith unaryTransactionCallback<T>.In order to disambiguate, a parameter or the callback interface should be explicitly stated:
I'm not sure how to fix it. Maybe let it break for bigger convenience in Java?