From 793a52c57a521f8f2935229049e809154b398046 Mon Sep 17 00:00:00 2001 From: Michele Sollecito Date: Mon, 3 Sep 2018 14:27:24 +0100 Subject: [PATCH] [CORDA-1542]: Exception error codes aren't stable (fixed). (#3887) --- .../net/corda/node/internal/NodeStartup.kt | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/node/src/main/kotlin/net/corda/node/internal/NodeStartup.kt b/node/src/main/kotlin/net/corda/node/internal/NodeStartup.kt index c73dfea87e..dfa8d113a9 100644 --- a/node/src/main/kotlin/net/corda/node/internal/NodeStartup.kt +++ b/node/src/main/kotlin/net/corda/node/internal/NodeStartup.kt @@ -147,8 +147,8 @@ open class NodeStartup(val args: Array) { val cause = this.cause return when { - cause != null && !visited.contains(cause) -> Objects.hash(this::class.java.name, stackTrace, cause.staticLocationBasedHash(visited + cause)) - else -> Objects.hash(this::class.java.name, stackTrace) + cause != null && !visited.contains(cause) -> Objects.hash(this::class.java.name, stackTrace.customHashCode(), cause.staticLocationBasedHash(visited + cause)) + else -> Objects.hash(this::class.java.name, stackTrace.customHashCode()) } } @@ -177,6 +177,19 @@ open class NodeStartup(val args: Array) { } } + private fun Array?.customHashCode(): Int { + + if (this == null) { + return 0 + } + return Arrays.hashCode(map { it?.customHashCode() ?: 0 }.toIntArray()) + } + + private fun StackTraceElement.customHashCode(): Int { + + return Objects.hash(StackTraceElement::class.java.name, methodName, lineNumber) + } + private fun configFileNotFoundMessage(configFile: Path): String { return """ Unable to load the node config file from '$configFile'. @@ -581,3 +594,5 @@ open class NodeStartup(val args: Array) { } } } + +