Skip to content

Newly added TransactionOperations.execute(Runnable) breaks existing Kotlin code #23724

Closed
@dittos

Description

@dittos

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?

Metadata

Metadata

Assignees

Labels

in: dataIssues in data modules (jdbc, orm, oxm, tx)type: regressionA bug that is also a regression

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions