mirror of
https://github.com/corda/corda.git
synced 2024-12-19 13:08:04 +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()
|
handleEndpointMap.clear()
|
||||||
messageReceiveQueues.clear()
|
messageReceiveQueues.clear()
|
||||||
|
timer.cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
@CordaSerializable
|
@CordaSerializable
|
||||||
|
@ -8,9 +8,10 @@ import java.nio.file.Path
|
|||||||
object ProcessUtilities {
|
object ProcessUtilities {
|
||||||
inline fun <reified C : Any> startJavaProcess(
|
inline fun <reified C : Any> startJavaProcess(
|
||||||
arguments: List<String>,
|
arguments: List<String>,
|
||||||
jdwpPort: Int? = null
|
jdwpPort: Int? = null,
|
||||||
|
extraJvmArguments: List<String> = emptyList()
|
||||||
): Process {
|
): 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(
|
fun startCordaProcess(
|
||||||
|
Loading…
Reference in New Issue
Block a user