Skip to content

Commit

Permalink
fixed non-determinism
Browse files Browse the repository at this point in the history
  • Loading branch information
arcuri82 committed May 22, 2024
1 parent 3e08331 commit fab78a0
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,10 @@ class Randomness {

val k = selection.subList(0, n)

if(log.isTraceEnabled) log.trace("Chosen: {}", k.joinToString(" "))
//printing actual values here lead to non-deterministic behavior is toString() is non-deterministic,
//which is the typical case for custom objects that do not override it, as output string will have
// a @ reference number to the heap
log.trace("Chosen {} elements from list", n)

return k
}
Expand All @@ -431,7 +434,7 @@ class Randomness {

val k = selection.subList(0, n).toSet()

if(log.isTraceEnabled) log.trace("Chosen: {}", k.joinToString(" "))
log.trace("Chosen {} elements from set", n)

return k
}
Expand All @@ -457,7 +460,7 @@ class Randomness {
}

val k = iter.next()
log.trace("Chosen: {}", k)
log.trace("Chosen index: {}", i)

return k
}
Expand Down

0 comments on commit fab78a0

Please sign in to comment.