Handle a negative value returned by Math.abs() #25034

This commit is contained in:
promanski 2018-05-01 16:43:56 +02:00 committed by Piotr Romański
parent 1ca612985e
commit 05282b59c9
9 changed files with 10 additions and 10 deletions

View file

@ -1623,7 +1623,7 @@ final class Replicator(settings: ReplicatorSettings) extends Actor with ActorLog
}
val chunk = (statusCount % totChunks).toInt
val status = Status(dataEntries.collect {
case (key, (_, _)) if math.abs(key.hashCode) % totChunks == chunk (key, getDigest(key))
case (key, (_, _)) if math.abs(key.hashCode % totChunks) == chunk (key, getDigest(key))
}, chunk, totChunks)
to ! status
}
@ -1651,7 +1651,7 @@ final class Replicator(settings: ReplicatorSettings) extends Actor with ActorLog
val otherKeys = otherDigests.keySet
val myKeys =
if (totChunks == 1) dataEntries.keySet
else dataEntries.keysIterator.filter(key math.abs(key.hashCode) % totChunks == chunk).toSet
else dataEntries.keysIterator.filter(key math.abs(key.hashCode % totChunks) == chunk).toSet
val otherMissingKeys = myKeys diff otherKeys
val keys = (otherDifferentKeys ++ otherMissingKeys).take(maxDeltaElements)
if (keys.nonEmpty) {