mirror of
https://github.com/corda/corda.git
synced 2025-01-31 00:24:59 +00:00
CORDA-2772 - fix edge case when stickTo.hashCode
return Int.MIN_VALUE
This commit is contained in:
parent
c33ccc1e1b
commit
b6f9b86998
@ -25,7 +25,12 @@ class LazyStickyPool<A : Any>(
|
|||||||
private val boxes = Array(size) { InstanceBox<A>() }
|
private val boxes = Array(size) { InstanceBox<A>() }
|
||||||
|
|
||||||
private fun toIndex(stickTo: Any): Int {
|
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 {
|
fun borrow(stickTo: Any): A {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user