From 3710385e9eec6ef63cfb82527912cf401699f9ab Mon Sep 17 00:00:00 2001 From: Andrew Kolpakov Date: Mon, 1 Dec 2014 13:25:38 +0600 Subject: [PATCH] Set.toArray and Set.iterator not grantees same keys order in all implementations --- src/main/java/org/redisson/RedissonMap.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/redisson/RedissonMap.java b/src/main/java/org/redisson/RedissonMap.java index d8dbd1041..6edeb792d 100644 --- a/src/main/java/org/redisson/RedissonMap.java +++ b/src/main/java/org/redisson/RedissonMap.java @@ -90,22 +90,21 @@ public class RedissonMap extends RedissonExpirable implements RMap { if (keys.size() == 0) { return Collections.emptyMap(); } + final Object[] keysArray = keys.toArray(); List list = connectionManager.read(new ResultOperation, V>() { @Override protected Future> execute(RedisAsyncConnection async) { - return async.hmget(getName(), keys.toArray()); + return async.hmget(getName(), keysArray); } }); Map result = new HashMap(list.size()); - int index = 0; - for (K key : keys) { + for (int index = 0; index < keysArray.length; index++) { V value = list.get(index); if (value == null) { continue; } - result.put(key, value); - index++; + result.put((K) keysArray[index], value); } return result; }