mirror of
https://github.com/corda/corda.git
synced 2025-01-29 15:43:55 +00:00
Prevent DemoBench hanging on shutdown (#722)
* We need to close the RPC client as otherwise the rpc-client-reaper-* thread is leaked, which also prevents shutdown. Sleep instead when the server exits, just long enough for the client to realise that the server is dead. * Fix warning about leaking private types.
This commit is contained in:
parent
3c89e65924
commit
975866590b
@ -11,7 +11,7 @@ import java.awt.Dimension
|
||||
import java.io.IOException
|
||||
import java.nio.charset.StandardCharsets.UTF_8
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.TimeUnit.SECONDS
|
||||
|
||||
class R3Pty(val name: X500Name, settings: SettingsProvider, dimension: Dimension, val onExit: (Int) -> Unit) : AutoCloseable {
|
||||
private companion object {
|
||||
@ -37,7 +37,7 @@ class R3Pty(val name: X500Name, settings: SettingsProvider, dimension: Dimension
|
||||
return PtyProcessTtyConnector(name.commonName, process, UTF_8)
|
||||
} catch (e: Exception) {
|
||||
process.destroyForcibly()
|
||||
process.waitFor(30, TimeUnit.SECONDS)
|
||||
process.waitFor(30, SECONDS)
|
||||
throw e
|
||||
}
|
||||
}
|
||||
@ -59,6 +59,8 @@ class R3Pty(val name: X500Name, settings: SettingsProvider, dimension: Dimension
|
||||
executor.submit {
|
||||
val exitValue = connector.waitFor()
|
||||
log.info("Terminal has exited (value={})", exitValue)
|
||||
// TODO: Remove this arbitrary sleep when https://github.com/corda/corda/issues/689 is fixed.
|
||||
try { Thread.sleep(SECONDS.toMillis(2)) } catch (e: InterruptedException) {}
|
||||
onExit(exitValue)
|
||||
}
|
||||
|
||||
@ -66,6 +68,7 @@ class R3Pty(val name: X500Name, settings: SettingsProvider, dimension: Dimension
|
||||
session.start()
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
@Throws(InterruptedException::class)
|
||||
fun waitFor(): Int? = terminal.ttyConnector?.waitFor()
|
||||
|
||||
|
@ -54,8 +54,7 @@ class NodeRPC(config: NodeConfig, start: (NodeConfig, CordaRPCOps) -> Unit, invo
|
||||
override fun close() {
|
||||
timer.cancel()
|
||||
try {
|
||||
// TODO: Uncomment when https://github.com/corda/corda/issues/689 is fixed
|
||||
// rpcConnection?.close()
|
||||
rpcConnection?.close()
|
||||
} catch (e: Exception) {
|
||||
log.error("Failed to close RPC connection (Error: {})", e.message)
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class NodeTabView : Fragment() {
|
||||
const val textWidth = 465.0
|
||||
|
||||
val jvm by inject<JVMConfig>()
|
||||
val cordappPathsFile = jvm.dataHome / "cordapp-paths.txt"
|
||||
val cordappPathsFile: Path = jvm.dataHome / "cordapp-paths.txt"
|
||||
|
||||
fun loadDefaultCordappPaths(): MutableList<Path> {
|
||||
if (cordappPathsFile.exists())
|
||||
|
Loading…
x
Reference in New Issue
Block a user