From b6f9b86998b29ecfd374fe860b77fdc72e1e411a Mon Sep 17 00:00:00 2001 From: dazraf Date: Thu, 21 Mar 2019 16:05:53 +0000 Subject: [PATCH] CORDA-2772 - fix edge case when `stickTo.hashCode` return `Int.MIN_VALUE` --- .../main/kotlin/net/corda/core/internal/LazyStickyPool.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/src/main/kotlin/net/corda/core/internal/LazyStickyPool.kt b/core/src/main/kotlin/net/corda/core/internal/LazyStickyPool.kt index 52ec2226ae..868997bc56 100644 --- a/core/src/main/kotlin/net/corda/core/internal/LazyStickyPool.kt +++ b/core/src/main/kotlin/net/corda/core/internal/LazyStickyPool.kt @@ -25,7 +25,12 @@ class LazyStickyPool( private val boxes = Array(size) { InstanceBox() } private fun toIndex(stickTo: Any): Int { - return Math.abs(stickTo.hashCode()) % boxes.size + return stickTo.hashCode().let { hashCode -> + when (hashCode) { + Int.MIN_VALUE -> 0 + else -> Math.abs(hashCode) % boxes.size + } + } } fun borrow(stickTo: Any): A {