[CORDA-1542]: Exception error codes aren't stable (fixed). (#3887)

This commit is contained in:
Michele Sollecito
2018-09-03 14:27:24 +01:00
committed by GitHub
parent 91dfa277e3
commit 793a52c57a

View File

@ -147,8 +147,8 @@ open class NodeStartup(val args: Array<String>) {
val cause = this.cause val cause = this.cause
return when { return when {
cause != null && !visited.contains(cause) -> Objects.hash(this::class.java.name, stackTrace, cause.staticLocationBasedHash(visited + cause)) 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) else -> Objects.hash(this::class.java.name, stackTrace.customHashCode())
} }
} }
@ -177,6 +177,19 @@ open class NodeStartup(val args: Array<String>) {
} }
} }
private fun Array<StackTraceElement?>?.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 { private fun configFileNotFoundMessage(configFile: Path): String {
return """ return """
Unable to load the node config file from '$configFile'. Unable to load the node config file from '$configFile'.
@ -581,3 +594,5 @@ open class NodeStartup(val args: Array<String>) {
} }
} }
} }