mirror of
https://github.com/corda/corda.git
synced 2024-12-23 14:52:29 +00:00
Fix MockNetwork non-daemon thread leak. (#2397)
This commit is contained in:
parent
f59560bb06
commit
d00438b86f
@ -0,0 +1,26 @@
|
||||
package net.corda.testing.node
|
||||
|
||||
import net.corda.core.internal.div
|
||||
import net.corda.testing.common.internal.ProjectStructure.projectRootDir
|
||||
import net.corda.testing.node.internal.ProcessUtilities.startJavaProcess
|
||||
import org.junit.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class MockNetworkIntegrationTests {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) {
|
||||
MockNetwork(emptyList()).run {
|
||||
repeat(2) { createNode() }
|
||||
runNetwork()
|
||||
stopNodes()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `does not leak non-daemon threads`() {
|
||||
val quasar = projectRootDir / "lib" / "quasar.jar"
|
||||
assertEquals(0, startJavaProcess<MockNetworkIntegrationTests>(emptyList(), extraJvmArguments = listOf("-javaagent:$quasar")).waitFor())
|
||||
}
|
||||
}
|
@ -161,6 +161,7 @@ class InMemoryMessagingNetwork internal constructor(
|
||||
|
||||
handleEndpointMap.clear()
|
||||
messageReceiveQueues.clear()
|
||||
timer.cancel()
|
||||
}
|
||||
|
||||
@CordaSerializable
|
||||
|
@ -8,9 +8,10 @@ import java.nio.file.Path
|
||||
object ProcessUtilities {
|
||||
inline fun <reified C : Any> startJavaProcess(
|
||||
arguments: List<String>,
|
||||
jdwpPort: Int? = null
|
||||
jdwpPort: Int? = null,
|
||||
extraJvmArguments: List<String> = emptyList()
|
||||
): Process {
|
||||
return startJavaProcessImpl(C::class.java.name, arguments, defaultClassPath, jdwpPort, emptyList(), null, null, null)
|
||||
return startJavaProcessImpl(C::class.java.name, arguments, defaultClassPath, jdwpPort, extraJvmArguments, null, null, null)
|
||||
}
|
||||
|
||||
fun startCordaProcess(
|
||||
|
Loading…
Reference in New Issue
Block a user