mirror of
https://github.com/corda/corda.git
synced 2025-01-31 00:24:59 +00:00
Move dbCloser to MockNode, the only thing that uses it. (#1512)
This commit is contained in:
parent
383eb2bef8
commit
12982b3034
@ -146,7 +146,6 @@ abstract class AbstractNode(open val configuration: NodeConfiguration,
|
||||
protected lateinit var network: MessagingService
|
||||
protected val runOnStop = ArrayList<() -> Any?>()
|
||||
protected lateinit var database: CordaPersistence
|
||||
protected var dbCloser: (() -> Any?)? = null
|
||||
lateinit var cordappProvider: CordappProviderImpl
|
||||
protected val cordappLoader by lazy { makeCordappLoader() }
|
||||
|
||||
@ -476,10 +475,7 @@ abstract class AbstractNode(open val configuration: NodeConfiguration,
|
||||
database.transaction {
|
||||
log.info("Connected to ${database.dataSource.connection.metaData.databaseProductName} database.")
|
||||
}
|
||||
this.database::close.let {
|
||||
dbCloser = it
|
||||
runOnStop += it
|
||||
}
|
||||
runOnStop += database::close
|
||||
return database.transaction {
|
||||
insideTransaction()
|
||||
}
|
||||
|
@ -241,6 +241,12 @@ class MockNetwork(private val networkSendManuallyPumped: Boolean = false,
|
||||
// It is used from the network visualiser tool.
|
||||
@Suppress("unused") val place: WorldMapLocation get() = findMyLocation()!!
|
||||
|
||||
private var dbCloser: (() -> Any?)? = null
|
||||
override fun <T> initialiseDatabasePersistence(insideTransaction: () -> T) = super.initialiseDatabasePersistence {
|
||||
dbCloser = database::close
|
||||
insideTransaction()
|
||||
}
|
||||
|
||||
fun disableDBCloseOnStop() {
|
||||
runOnStop.remove(dbCloser)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user