From a4e50abb37da14ed318a19b5eba3bd489067767e Mon Sep 17 00:00:00 2001 From: "Andrey.Tarashevskiy" Date: Thu, 3 Jun 2021 10:11:12 +0300 Subject: [PATCH] TransactionScope throws NullPointerException when attempting to commit #1250 --- .../org/jetbrains/exposed/sql/transactions/TransactionScope.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/transactions/TransactionScope.kt b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/transactions/TransactionScope.kt index eb0981cbda..cc1d2d24e8 100644 --- a/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/transactions/TransactionScope.kt +++ b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/transactions/TransactionScope.kt @@ -18,7 +18,7 @@ class TransactionStore(val init: (Transaction.() -> T)? = null) : ReadW val currentOrNullTransaction = TransactionManager.currentOrNull() return currentOrNullTransaction?.getUserData(key) ?: init?.let { - val value = currentOrNullTransaction!!.it() + val value = currentOrNullTransaction?.it() ?: error("Can't init value outside the transaction") currentOrNullTransaction.putUserData(key, value) value }