Skip to content

Commit

Permalink
feat: reset outer tx manager when transaction clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
FullOfOrange committed Aug 25, 2023
1 parent 5268df3 commit 7dcb3e3
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ class SpringTransactionManager(
}

override fun doGetTransaction(): Any {
val outerManager = TransactionManager.manager
val outer = threadLocalTransactionManager.currentOrNull()

return ExposedTransactionObject(
manager = threadLocalTransactionManager,
outerTransaction = outer
outerManager = outerManager,
outerTransaction = outer,
)
}

Expand Down Expand Up @@ -82,7 +84,7 @@ class SpringTransactionManager(
}

trxObject.setCurrentToOuter()
TransactionManager.resetCurrent(null)
TransactionManager.resetCurrent(trxObject.outerManager)
}

private fun closeStatementsAndConnections(transaction: Transaction) {
Expand Down Expand Up @@ -113,6 +115,7 @@ class SpringTransactionManager(

private data class ExposedTransactionObject(
val manager: TransactionManager,
val outerManager: TransactionManager,
private val outerTransaction: Transaction?,
) : SmartTransactionObject {

Expand Down

0 comments on commit 7dcb3e3

Please sign in to comment.