From 1e6b8ec86b1688eb1fd4675b48f4fc2c6e8f28c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Andr=C3=A9n?= Date: Mon, 13 Mar 2017 17:57:03 +0100 Subject: [PATCH] Make sure the hashcode is not negative when selecting key chunk #22487 --- .../src/main/scala/akka/cluster/ddata/Replicator.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/akka-distributed-data/src/main/scala/akka/cluster/ddata/Replicator.scala b/akka-distributed-data/src/main/scala/akka/cluster/ddata/Replicator.scala index 2735df3ffa..138155b71c 100644 --- a/akka-distributed-data/src/main/scala/akka/cluster/ddata/Replicator.scala +++ b/akka-distributed-data/src/main/scala/akka/cluster/ddata/Replicator.scala @@ -1558,7 +1558,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(_.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) {