diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnection.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnection.java index f93305cd5..f10437cb5 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnection.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnection.java @@ -19,8 +19,8 @@ import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collections; -import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -3107,21 +3107,21 @@ public class JedisConnection extends AbstractRedisConnection { private Map zAddArgs(Set tuples) { - Map args = new HashMap(); + Map args = new LinkedHashMap(tuples.size(), 1); + Set scores = new HashSet(tuples.size(), 1); - if (!JedisVersionUtil.atLeastJedis24()) { - int size = (int) (tuples.size() / 0.75) + 1; - Set scores = new HashSet(size); - for (Tuple tuple : tuples) { + boolean isAtLeastJedis24 = JedisVersionUtil.atLeastJedis24(); + + for (Tuple tuple : tuples) { + + if (!isAtLeastJedis24) { if (scores.contains(tuple.getScore())) { throw new UnsupportedOperationException( "Bulk add of multiple elements with the same score is not supported. Add the elements individually."); } scores.add(tuple.getScore()); } - } - for (Tuple tuple : tuples) { args.put(tuple.getValue(), tuple.getScore()); }