From 8f4973cd00ab42dd530ad89fea30b5bf98cbd322 Mon Sep 17 00:00:00 2001 From: Florian Friemel Date: Thu, 14 Jun 2018 13:09:03 +0100 Subject: [PATCH] [CORDA-1617] Fix explorer login error handling. (#3365) When specifying incorrect connection details for the nodes (e.g., wrong port), an RPCException would be thrown which was not handled correctly, resulting in busy waiting on the UI thread. Ideally the login should not block the UI thread anyways, but for now this fix is the most pragmatic solution. --- .../client/jfx/model/NodeMonitorModel.kt | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/client/jfx/src/main/kotlin/net/corda/client/jfx/model/NodeMonitorModel.kt b/client/jfx/src/main/kotlin/net/corda/client/jfx/model/NodeMonitorModel.kt index 07cb4f3797..0194edb110 100644 --- a/client/jfx/src/main/kotlin/net/corda/client/jfx/model/NodeMonitorModel.kt +++ b/client/jfx/src/main/kotlin/net/corda/client/jfx/model/NodeMonitorModel.kt @@ -6,6 +6,7 @@ import javafx.beans.property.SimpleObjectProperty import net.corda.client.rpc.CordaRPCClient import net.corda.client.rpc.CordaRPCClientConfiguration import net.corda.client.rpc.CordaRPCConnection +import net.corda.client.rpc.RPCException import net.corda.core.contracts.ContractState import net.corda.core.flows.StateMachineRunId import net.corda.core.identity.Party @@ -193,18 +194,22 @@ class NodeMonitorModel { val nodeInfo = _connection.proxy.nodeInfo() require(nodeInfo.legalIdentitiesAndCerts.isNotEmpty()) _connection - } catch (secEx: ActiveMQException) { - // Happens when: - // * incorrect credentials provided; - // * incorrect endpoint specified; - // - no point to retry connecting. - throw secEx - } catch (th: Throwable) { - // Deliberately not logging full stack trace as it will be full of internal stacktraces. - logger.info("Exception upon establishing connection: " + th.message) - null + } catch (throwable: Throwable) { + when (throwable) { + is ActiveMQException, is RPCException -> { + // Happens when: + // * incorrect credentials provided; + // * incorrect endpoint specified; + // - no point to retry connecting. + throw throwable + } + else -> { + // Deliberately not logging full stack trace as it will be full of internal stacktraces. + logger.info("Exception upon establishing connection: " + throwable.message) + null + } + } } - if (connection != null) { logger.info("Connection successfully established with: $nodeHostAndPort") return connection