Avoid returning Throwable as Future value. (#1124)

This commit is contained in:
Andrzej Cichocki 2017-08-01 17:24:19 +01:00 committed by GitHub
parent 2c62f8968a
commit fbb3fe0dfa

View File

@ -513,7 +513,7 @@ class DriverDSL(
_executorService?.shutdownNow()
}
private fun establishRpc(nodeAddress: NetworkHostAndPort, sslConfig: SSLConfiguration, processDeathFuture: ListenableFuture<out Throwable>): ListenableFuture<CordaRPCOps> {
private fun establishRpc(nodeAddress: NetworkHostAndPort, sslConfig: SSLConfiguration, processDeathFuture: ListenableFuture<out Process>): ListenableFuture<CordaRPCOps> {
val client = CordaRPCClient(nodeAddress, sslConfig, initialiseSerialization = false)
val connectionFuture = poll(executorService, "RPC connection") {
try {
@ -526,7 +526,7 @@ class DriverDSL(
}
return firstOf(connectionFuture, processDeathFuture) {
if (it == processDeathFuture) {
throw processDeathFuture.getOrThrow()
throw ListenProcessDeathException(nodeAddress, processDeathFuture.getOrThrow())
}
val connection = connectionFuture.getOrThrow()
shutdownManager.registerShutdown(connection::close)
@ -726,7 +726,7 @@ class DriverDSL(
registerProcess(processFuture)
return processFuture.flatMap { process ->
val processDeathFuture = poll(executorService, "process death") {
if (process.isAlive) null else ListenProcessDeathException(nodeConfiguration.p2pAddress, process)
if (process.isAlive) null else process
}
// We continue to use SSL enabled port for RPC when its for node user.
establishRpc(nodeConfiguration.p2pAddress, nodeConfiguration, processDeathFuture).flatMap { rpc ->
@ -736,7 +736,7 @@ class DriverDSL(
}).flatMap { it }
firstOf(processDeathFuture, networkMapFuture) {
if (it == processDeathFuture) {
throw processDeathFuture.getOrThrow()
throw ListenProcessDeathException(nodeConfiguration.p2pAddress, process)
}
processDeathFuture.cancel(false)
NodeHandle.OutOfProcess(rpc.nodeIdentity(), rpc, nodeConfiguration, webAddress, debugPort, process)