diff --git a/client/src/main/kotlin/net/corda/client/mock/Generator.kt b/client/src/main/kotlin/net/corda/client/mock/Generator.kt
index ccc0df1b2f..c0fba098e1 100644
--- a/client/src/main/kotlin/net/corda/client/mock/Generator.kt
+++ b/client/src/main/kotlin/net/corda/client/mock/Generator.kt
@@ -176,14 +176,15 @@ fun Generator.Companion.replicatePoisson(meanSize: Double, generator:
fun Generator.Companion.pickOne(list: List) = Generator.intRange(0, list.size - 1).map { list[it] }
fun Generator.Companion.pickN(number: Int, list: List) = Generator> {
val mask = BitSet(list.size)
- for (i in 0..Math.min(list.size, number) - 1) {
- mask[i] = 1
+ val size = Math.min(list.size, number)
+ for (i in 0..size - 1) {
+ mask[i] = true
}
- for (i in 0..mask.size() - 1) {
- val byte = mask[i]
- val swapIndex = i + it.nextInt(mask.size() - i)
+ for (i in 0..size - 1) {
+ val bit = mask[i]
+ val swapIndex = i + it.nextInt(size - i)
mask[i] = mask[swapIndex]
- mask[swapIndex] = byte
+ mask[swapIndex] = bit
}
val resultList = ArrayList()
list.forEachIndexed { index, a ->