From 47c7be62c0925f0f5c1f27eb256ad69569c95425 Mon Sep 17 00:00:00 2001 From: bpaunescu Date: Mon, 26 Mar 2018 14:27:35 +0100 Subject: [PATCH] ENT-1670: update kdocs and unit test for better user experience (#2875) * ENT-1670: update kdocs and unit test for better user experience regarding RPC connection loss * RPCStabilityTests: move doOnError logic to onError handler --- .../kotlin/net/corda/client/rpc/RPCStabilityTests.kt | 9 +++++++-- .../main/kotlin/net/corda/client/rpc/CordaRPCClient.kt | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/RPCStabilityTests.kt b/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/RPCStabilityTests.kt index 99cfc38e2a..e7452d49ab 100644 --- a/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/RPCStabilityTests.kt +++ b/client/rpc/src/integration-test/kotlin/net/corda/client/rpc/RPCStabilityTests.kt @@ -305,16 +305,21 @@ class RPCStabilityTests { var terminateHandlerCalled = false var errorHandlerCalled = false + var exceptionMessage: String? = null val subscription = client.subscribe() .doOnTerminate{ terminateHandlerCalled = true } - .doOnError { errorHandlerCalled = true } - .subscribe() + .subscribe({}, { + errorHandlerCalled = true + //log exception + exceptionMessage = it.message + }) serverFollower.shutdown() Thread.sleep(100) assertTrue(terminateHandlerCalled) assertTrue(errorHandlerCalled) + assertEquals("Connection failure detected.", exceptionMessage) assertTrue(subscription.isUnsubscribed) clientFollower.shutdown() // Driver would do this after the new server, causing hang. diff --git a/client/rpc/src/main/kotlin/net/corda/client/rpc/CordaRPCClient.kt b/client/rpc/src/main/kotlin/net/corda/client/rpc/CordaRPCClient.kt index 4e4c6c99cc..ed4ad14a23 100644 --- a/client/rpc/src/main/kotlin/net/corda/client/rpc/CordaRPCClient.kt +++ b/client/rpc/src/main/kotlin/net/corda/client/rpc/CordaRPCClient.kt @@ -89,6 +89,10 @@ interface CordaRPCClientConfiguration { * with an error, the observable is closed and you can't then re-subscribe again: you'll have to re-request a fresh * observable with another RPC. * + * In case of loss of connection to the server, the client will try to reconnect using the settings provided via + * [CordaRPCClientConfiguration]. While attempting failover, current and future RPC calls will throw + * [RPCException] and previously returned observables will call onError(). + * * @param hostAndPort The network address to connect to. * @param configuration An optional configuration used to tweak client behaviour. * @param sslConfiguration An optional [SSLConfiguration] used to enable secure communication with the server.