mirror of
https://github.com/corda/corda.git
synced 2025-06-22 09:08:49 +00:00
Merge remote-tracking branch 'open/master' into os-merge-757181e
# Conflicts: # node-api/src/main/kotlin/net/corda/nodeapi/internal/persistence/CordaPersistence.kt # node/src/integration-test/kotlin/net/corda/node/services/messaging/ArtemisMessagingTest.kt # node/src/main/kotlin/net/corda/node/internal/AbstractNode.kt # node/src/main/kotlin/net/corda/node/internal/Node.kt # node/src/main/kotlin/net/corda/node/services/messaging/P2PMessagingClient.kt # node/src/main/kotlin/net/corda/node/services/vault/NodeVaultService.kt # node/src/test/kotlin/net/corda/node/internal/NodeTest.kt # node/src/test/kotlin/net/corda/node/services/identity/PersistentIdentityServiceTests.kt # testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/InternalMockNetwork.kt
This commit is contained in:
@ -61,7 +61,6 @@ var contextDatabase: CordaPersistence
|
||||
val contextDatabaseOrNull: CordaPersistence? get() = _contextDatabase.get()
|
||||
|
||||
class CordaPersistence(
|
||||
val dataSource: DataSource,
|
||||
databaseConfig: DatabaseConfig,
|
||||
schemas: Set<MappedSchema>,
|
||||
val jdbcUrl: String,
|
||||
@ -82,7 +81,11 @@ class CordaPersistence(
|
||||
|
||||
data class Boundary(val txId: UUID, val success: Boolean)
|
||||
|
||||
init {
|
||||
private var _dataSource: DataSource? = null
|
||||
val dataSource: DataSource get() = checkNotNull(_dataSource) { "CordaPersistence not started" }
|
||||
|
||||
fun start(dataSource: DataSource) {
|
||||
_dataSource = dataSource
|
||||
// Found a unit test that was forgetting to close the database transactions. When you close() on the top level
|
||||
// database transaction it will reset the threadLocalTx back to null, so if it isn't then there is still a
|
||||
// database transaction open. The [transaction] helper above handles this in a finally clause for you
|
||||
@ -94,10 +97,10 @@ class CordaPersistence(
|
||||
// Check not in read-only mode.
|
||||
transaction {
|
||||
check(!connection.metaData.isReadOnly) { "Database should not be readonly." }
|
||||
}
|
||||
}
|
||||
|
||||
object DataSourceConfigTag {
|
||||
}
|
||||
}
|
||||
object DataSourceConfigTag {
|
||||
const val DATA_SOURCE_URL = "dataSource.url"
|
||||
}
|
||||
|
||||
@ -189,7 +192,7 @@ class CordaPersistence(
|
||||
|
||||
override fun close() {
|
||||
// DataSource doesn't implement AutoCloseable so we just have to hope that the implementation does so that we can close it
|
||||
(dataSource as? AutoCloseable)?.close()
|
||||
(_dataSource as? AutoCloseable)?.close()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,9 @@ class AttachmentsClassLoaderStaticContractTests {
|
||||
}
|
||||
|
||||
private val serviceHub = rigorousMock<ServicesForResolution>().also {
|
||||
doReturn(CordappProviderImpl(cordappLoaderForPackages(listOf("net.corda.nodeapi.internal")), MockCordappConfigProvider(), MockAttachmentStorage(), testNetworkParameters().whitelistedContractImplementations)).whenever(it).cordappProvider
|
||||
val cordappProviderImpl = CordappProviderImpl(cordappLoaderForPackages(listOf("net.corda.nodeapi.internal")), MockCordappConfigProvider(), MockAttachmentStorage())
|
||||
cordappProviderImpl.start(testNetworkParameters().whitelistedContractImplementations)
|
||||
doReturn(cordappProviderImpl).whenever(it).cordappProvider
|
||||
doReturn(testNetworkParameters()).whenever(it).networkParameters
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user