diff --git a/build.gradle b/build.gradle index 9ae8e9bdf9..d39c3937c4 100644 --- a/build.gradle +++ b/build.gradle @@ -110,7 +110,7 @@ buildscript { ext.jsr305_version = constants.getProperty("jsr305Version") ext.shiro_version = '1.10.0' ext.artifactory_plugin_version = constants.getProperty('artifactoryPluginVersion') - ext.hikari_version = '3.3.1' + ext.hikari_version = '4.0.3' ext.liquibase_version = '3.6.3' ext.artifactory_contextUrl = 'https://software.r3.com/artifactory' ext.publicArtifactURL = 'https://download.corda.net/maven' diff --git a/node/src/test/kotlin/net/corda/node/migration/MemoryLeakTest.kt b/node/src/test/kotlin/net/corda/node/migration/MemoryLeakTest.kt new file mode 100644 index 0000000000..aeb57d8c9b --- /dev/null +++ b/node/src/test/kotlin/net/corda/node/migration/MemoryLeakTest.kt @@ -0,0 +1,39 @@ +package net.corda.node.migration + +import net.corda.testing.core.ALICE_NAME +import net.corda.testing.node.MockNetwork +import net.corda.testing.node.MockNetworkParameters +import net.corda.testing.node.internal.cordappsForPackages +import org.apache.commons.lang3.SystemUtils +import org.hibernate.internal.SessionFactoryRegistry +import org.junit.Assume +import org.junit.Test +import kotlin.test.assertFalse + +class MemoryLeakTest { + @Test(timeout=300_000) + fun `memory leak test`() { + assertFalse(SessionFactoryRegistry.INSTANCE.hasRegistrations()) + repeat(1) { + // Start mock network + Assume.assumeTrue(!SystemUtils.IS_JAVA_11) + val mockNetwork = MockNetwork( + MockNetworkParameters( + cordappsForAllNodes = cordappsForPackages( + listOf( + "net.corda.node.services.vault" + ) + ) + ) + ).also { mockNetwork -> + mockNetwork.createPartyNode(ALICE_NAME) + } + + // Stop mock network + mockNetwork?.stopNodes() + // mockNetwork = null + } + assertFalse(SessionFactoryRegistry.INSTANCE.hasRegistrations()) + } +} + diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/InternalMockNetwork.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/InternalMockNetwork.kt index 4df37b8258..fdaf4a9565 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/InternalMockNetwork.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/InternalMockNetwork.kt @@ -73,6 +73,7 @@ import net.corda.testing.node.MockServices.Companion.makeTestDataSourcePropertie import net.corda.testing.node.TestClock import org.apache.activemq.artemis.utils.ReusableLatch import org.apache.sshd.common.util.security.SecurityUtils +import org.hibernate.internal.SessionFactoryRegistry import rx.Observable import rx.Scheduler import rx.internal.schedulers.CachedThreadScheduler @@ -621,6 +622,7 @@ open class InternalMockNetwork(cordappPackages: List = emptyList(), } messagingNetwork.stop() } + SessionFactoryRegistry.INSTANCE.clearRegistrations() } /** Block until all scheduled activity, active flows and network activity has ceased. */