Fixed - RStream.getInfo() method doesn't decode entries #3457

pull/3245/merge
Nikita Koksharov 4 years ago
parent cf011bf929
commit af7a76b25c

@ -50,7 +50,7 @@ public class RedissonLocalCachedMap<K, V> extends RedissonMap<K, V> implements R
private static final RedisCommand<Set<Object>> ALL_KEYS = new RedisCommand<Set<Object>>("EVAL", new MapKeyDecoder(new ObjectSetReplayDecoder<Object>()));
private static final RedisCommand<Set<Entry<Object, Object>>> ALL_ENTRIES = new RedisCommand<Set<Entry<Object, Object>>>("EVAL", new MapEntriesDecoder(new ObjectMapEntryReplayDecoder()));
private static final RedisCommand<Map<Object, Object>> ALL_MAP = new RedisCommand<Map<Object, Object>>("EVAL", new MapEntriesDecoder(new ObjectMapReplayDecoder()));
private static final RedisCommand<Map<Object, Object>> ALL_MAP = new RedisCommand<Map<Object, Object>>("EVAL", new ObjectMapReplayDecoder());
private long cacheUpdateLogTime = TimeUnit.MINUTES.toMillis(10);
private byte[] instanceId;

@ -26,10 +26,7 @@ import org.redisson.client.codec.Codec;
import org.redisson.client.codec.StringCodec;
import org.redisson.client.protocol.RedisCommand;
import org.redisson.client.protocol.RedisCommands;
import org.redisson.client.protocol.decoder.CodecDecoder;
import org.redisson.client.protocol.decoder.ListMultiDecoder2;
import org.redisson.client.protocol.decoder.ObjectMapDecoder;
import org.redisson.client.protocol.decoder.StreamInfoDecoder;
import org.redisson.client.protocol.decoder.*;
import org.redisson.command.CommandAsyncExecutor;
/**
@ -1083,7 +1080,12 @@ public class RedissonStream<K, V> extends RedissonExpirable implements RStream<K
@Override
public RFuture<StreamInfo<K, V>> getInfoAsync() {
return commandExecutor.readAsync(getName(), StringCodec.INSTANCE, XINFO_STREAM, getName());
RedisCommand<StreamInfo<Object, Object>> xinfoStream = new RedisCommand<>("XINFO", "STREAM",
new ListMultiDecoder2(
new StreamInfoDecoder(),
new CodecDecoder(),
new ObjectMapReplayDecoder(codec)));
return commandExecutor.readAsync(getName(), StringCodec.INSTANCE, xinfoStream, getName());
}
@Override

@ -240,7 +240,7 @@ public interface RedisCommands {
RedisCommand<Set<Entry<Object, Object>>> EVAL_MAP_ENTRY = new RedisCommand<Set<Entry<Object, Object>>>("EVAL",
new MapEntriesDecoder(new ObjectMapEntryReplayDecoder()));
RedisCommand<Map<Object, Object>> EVAL_MAP = new RedisCommand<Map<Object, Object>>("EVAL",
new MapEntriesDecoder(new ObjectMapReplayDecoder()));
new ObjectMapReplayDecoder());
RedisCommand<List<Object>> EVAL_MAP_VALUE_LIST = new RedisCommand<List<Object>>("EVAL",
new MapValueDecoder(new ObjectListReplayDecoder<>()));
RedisCommand<Set<Object>> EVAL_MAP_VALUE_SET = new RedisCommand<Set<Object>>("EVAL",
@ -280,13 +280,13 @@ public interface RedisCommands {
RedisCommand<MapScanResult<Object, Object>> HSCAN =
new RedisCommand<MapScanResult<Object, Object>>("HSCAN",
new ListMultiDecoder2(new MapScanResultReplayDecoder(),
new MapEntriesDecoder(new ObjectMapReplayDecoder())));
new ObjectMapReplayDecoder()));
RedisCommand<Map<Object, Object>> HRANDFIELD = new RedisCommand<>("HRANDFIELD",
new MapEntriesDecoder(new ObjectMapReplayDecoder()), new EmptyMapConvertor());
new ObjectMapReplayDecoder(), new EmptyMapConvertor());
RedisCommand<Set<Object>> HRANDFIELD_KEYS = new RedisCommand<>("HRANDFIELD",
new MapKeyDecoder(new ObjectSetReplayDecoder<>()), new EmptySetConvertor());
RedisCommand<Map<Object, Object>> HGETALL = new RedisCommand<Map<Object, Object>>("HGETALL",
new MapEntriesDecoder(new ObjectMapReplayDecoder()));
new ObjectMapReplayDecoder());
RedisCommand<Set<Entry<Object, Object>>> HGETALL_ENTRY = new RedisCommand<Set<Entry<Object, Object>>>("HGETALL",
new MapEntriesDecoder(new ObjectMapEntryReplayDecoder()));
RedisCommand<List<Object>> HVALS = new RedisCommand<List<Object>>("HVALS",

@ -15,11 +15,14 @@
*/
package org.redisson.client.protocol.decoder;
import org.redisson.client.codec.Codec;
import org.redisson.client.handler.State;
import org.redisson.client.protocol.Decoder;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
/**
*
@ -28,6 +31,25 @@ import java.util.Map;
*/
public class ObjectMapReplayDecoder<K, V> implements MultiDecoder<Map<K, V>> {
private final Codec codec;
public ObjectMapReplayDecoder(Codec codec) {
this.codec = codec;
}
public ObjectMapReplayDecoder() {
this(null);
}
@Override
public Decoder<Object> getDecoder(Codec codec, int paramNum, State state) {
if (paramNum % 2 != 0) {
return Optional.ofNullable(this.codec).orElse(codec).getMapValueDecoder();
} else {
return Optional.ofNullable(this.codec).orElse(codec).getMapKeyDecoder();
}
}
@Override
public Map<K, V> decode(List<Object> parts, State state) {
Map<K, V> result = new LinkedHashMap<>(parts.size()/2);

Loading…
Cancel
Save