Skip to content

Commit

Permalink
CORDA-2772 - fix edge case when stickTo.hashCode return `Int.MIN_VA…
Browse files Browse the repository at this point in the history
…LUE`
  • Loading branch information
dazraf authored and Mike Hearn committed Mar 22, 2019
1 parent c33ccc1 commit b6f9b86
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ class LazyStickyPool<A : Any>(
private val boxes = Array(size) { InstanceBox<A>() }

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 {
Expand Down

0 comments on commit b6f9b86

Please sign in to comment.