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
This commit is contained in:
bpaunescu 2018-03-26 14:27:35 +01:00 committed by GitHub
parent c3031b182b
commit 47c7be62c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -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.

View File

@ -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.