diff --git a/src/main/java/org/redisson/client/RedisPubSubConnection.java b/src/main/java/org/redisson/client/RedisPubSubConnection.java index af152ad2a..43ffc0a01 100644 --- a/src/main/java/org/redisson/client/RedisPubSubConnection.java +++ b/src/main/java/org/redisson/client/RedisPubSubConnection.java @@ -20,7 +20,7 @@ import java.util.concurrent.ConcurrentLinkedQueue; import org.redisson.client.handler.RedisData; import org.redisson.client.protocol.RedisCommand; import org.redisson.client.protocol.RedisCommands; -import org.redisson.client.protocol.pubsub.MultiDecoder; +import org.redisson.client.protocol.decoder.MultiDecoder; import org.redisson.client.protocol.pubsub.PubSubMessage; import org.redisson.client.protocol.pubsub.PubSubMessageDecoder; import org.redisson.client.protocol.pubsub.PubSubPatternMessage; diff --git a/src/main/java/org/redisson/client/handler/RedisData.java b/src/main/java/org/redisson/client/handler/RedisData.java index 9c925ca78..d07bee59b 100644 --- a/src/main/java/org/redisson/client/handler/RedisData.java +++ b/src/main/java/org/redisson/client/handler/RedisData.java @@ -19,7 +19,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import org.redisson.client.protocol.Codec; import org.redisson.client.protocol.RedisCommand; -import org.redisson.client.protocol.pubsub.MultiDecoder; +import org.redisson.client.protocol.decoder.MultiDecoder; import io.netty.util.concurrent.Promise; diff --git a/src/main/java/org/redisson/client/handler/RedisDecoder.java b/src/main/java/org/redisson/client/handler/RedisDecoder.java index 3e04b5f19..29b48bc55 100644 --- a/src/main/java/org/redisson/client/handler/RedisDecoder.java +++ b/src/main/java/org/redisson/client/handler/RedisDecoder.java @@ -28,7 +28,7 @@ import org.redisson.client.RedisPubSubConnection; import org.redisson.client.handler.RedisCommandsQueue.QueueCommands; import org.redisson.client.protocol.Decoder; import org.redisson.client.protocol.RedisCommand.ValueType; -import org.redisson.client.protocol.pubsub.MultiDecoder; +import org.redisson.client.protocol.decoder.MultiDecoder; import org.redisson.client.protocol.pubsub.PubSubMessage; import org.redisson.client.protocol.pubsub.PubSubPatternMessage; @@ -62,7 +62,11 @@ public class RedisDecoder extends ReplayingDecoder { System.out.println("message " + in.writerIndex() + "-" + in.readerIndex() + " in: " + in.toString(0, in.writerIndex(), CharsetUtil.UTF_8)); - decode(in, data, null, pubSubConnection, currentDecoder); + try { + decode(in, data, null, pubSubConnection, currentDecoder); + } catch (Exception e) { + data.getPromise().setFailure(e); + } ctx.channel().attr(RedisCommandsQueue.REPLAY).remove(); ctx.pipeline().fireUserEventTriggered(QueueCommands.NEXT_COMMAND); @@ -103,7 +107,7 @@ public class RedisDecoder extends ReplayingDecoder { decode(in, data, respParts, pubSubConnection, currentDecoder); } - Object result = messageDecoder(data, respParts).decode(respParts); + Object result = messageDecoder(data, respParts).get().decode(respParts); handleMultiResult(data, parts, pubSubConnection, result); } else { throw new IllegalStateException("Can't decode replay " + (char)code); diff --git a/src/main/java/org/redisson/client/handler/RedisEncoder.java b/src/main/java/org/redisson/client/handler/RedisEncoder.java index 3e53c7939..c9868f603 100644 --- a/src/main/java/org/redisson/client/handler/RedisEncoder.java +++ b/src/main/java/org/redisson/client/handler/RedisEncoder.java @@ -46,10 +46,17 @@ public class RedisEncoder extends MessageToByteEncoder int i = 1; for (Object param : msg.getParams()) { Encoder encoder = msg.getCommand().getParamsEncoder(); - if (msg.getCommand().getInParamIndex() == i && msg.getCommand().getInParamType() == ValueType.OBJECT) { - encoder = msg.getCodec().getValueEncoder(); - } else if (msg.getCommand().getInParamIndex() <= i && msg.getCommand().getInParamType() != ValueType.OBJECT) { - encoder = encoder(msg, i - msg.getCommand().getInParamIndex()); + if (msg.getCommand().getInParamType().size() == 1) { + if (msg.getCommand().getInParamIndex() == i && msg.getCommand().getInParamType().get(0) == ValueType.OBJECT) { + encoder = msg.getCodec().getValueEncoder(); + } else if (msg.getCommand().getInParamIndex() <= i && msg.getCommand().getInParamType().get(0) != ValueType.OBJECT) { + encoder = encoder(msg, i - msg.getCommand().getInParamIndex()); + } + } else { + int paramNum = i - msg.getCommand().getInParamIndex(); + if (msg.getCommand().getInParamIndex() <= i) { + encoder = encoder(msg, paramNum); + } } writeArgument(out, encoder.encode(i, param)); @@ -62,17 +69,21 @@ public class RedisEncoder extends MessageToByteEncoder } private Encoder encoder(RedisData msg, int param) { - if (msg.getCommand().getInParamType() == ValueType.MAP) { + int typeIndex = 0; + if (msg.getCommand().getInParamType().size() > 1) { + typeIndex = param; + } + if (msg.getCommand().getInParamType().get(typeIndex) == ValueType.MAP) { if (param % 2 != 0) { return msg.getCodec().getMapValueEncoder(); } else { return msg.getCodec().getMapKeyEncoder(); } } - if (msg.getCommand().getInParamType() == ValueType.MAP_KEY) { + if (msg.getCommand().getInParamType().get(typeIndex) == ValueType.MAP_KEY) { return msg.getCodec().getMapKeyEncoder(); } - if (msg.getCommand().getInParamType() == ValueType.MAP_KEY) { + if (msg.getCommand().getInParamType().get(typeIndex) == ValueType.MAP_VALUE) { return msg.getCodec().getMapValueEncoder(); } throw new IllegalStateException(); diff --git a/src/main/java/org/redisson/client/protocol/RedisCommand.java b/src/main/java/org/redisson/client/protocol/RedisCommand.java index 9b8ddaed5..cc3ee6c2a 100644 --- a/src/main/java/org/redisson/client/protocol/RedisCommand.java +++ b/src/main/java/org/redisson/client/protocol/RedisCommand.java @@ -15,14 +15,17 @@ */ package org.redisson.client.protocol; -import org.redisson.client.protocol.pubsub.MultiDecoder; +import java.util.Arrays; +import java.util.List; + +import org.redisson.client.protocol.decoder.MultiDecoder; public class RedisCommand { public enum ValueType {OBJECT, MAP_VALUE, MAP_KEY, MAP} private ValueType outParamType = ValueType.OBJECT; - private ValueType inParamType = ValueType.OBJECT; + private List inParamType = Arrays.asList(ValueType.OBJECT); private final int inParamIndex; private final String name; @@ -42,6 +45,17 @@ public class RedisCommand { this.outParamType = outParamType; } + public RedisCommand(String name, int objectParamIndex, ValueType inParamType) { + this(name, null, null, null, objectParamIndex); + this.inParamType = Arrays.asList(inParamType); + } + + public RedisCommand(String name, ValueType inParamType, ValueType outParamType) { + this(name, (String)null); + this.inParamType = Arrays.asList(inParamType); + this.outParamType = outParamType; + } + public RedisCommand(String name, String subName) { this(name, subName, null, null, -1); } @@ -56,15 +70,31 @@ public class RedisCommand { public RedisCommand(String name, int encodeParamIndex, ValueType inParamType, ValueType outParamType) { this(name, null, null, null, encodeParamIndex); + this.inParamType = Arrays.asList(inParamType); + this.outParamType = outParamType; + } + + public RedisCommand(String name, int encodeParamIndex, List inParamType, ValueType outParamType) { + this(name, null, null, null, encodeParamIndex); + this.inParamType = inParamType; + this.outParamType = outParamType; + } + + public RedisCommand(String name, Decoder reponseDecoder, int encodeParamIndex, List inParamType, ValueType outParamType) { + this(name, null, null, reponseDecoder, encodeParamIndex); this.inParamType = inParamType; this.outParamType = outParamType; } + public RedisCommand(String name, Decoder reponseDecoder, int encodeParamIndex, List inParamType) { + this(name, null, null, reponseDecoder, encodeParamIndex); + this.inParamType = inParamType; + } public RedisCommand(String name, Convertor convertor, int encodeParamIndex, ValueType inParamType) { this(name, null, null, null, encodeParamIndex); this.convertor = convertor; - this.inParamType = inParamType; + this.inParamType = Arrays.asList(inParamType); } public RedisCommand(String name, Convertor convertor, int encodeParamIndex) { @@ -78,7 +108,7 @@ public class RedisCommand { public RedisCommand(String name, Decoder reponseDecoder, int objectParamIndex, ValueType inParamType) { this(name, null, null, reponseDecoder, objectParamIndex); - this.inParamType = inParamType; + this.inParamType = Arrays.asList(inParamType); } public RedisCommand(String name, Decoder reponseDecoder, int objectParamIndex) { @@ -93,7 +123,7 @@ public class RedisCommand { public RedisCommand(String name, MultiDecoder replayMultiDecoder, int objectParamIndex, ValueType inParamType, ValueType outParamType) { this(name, replayMultiDecoder, objectParamIndex); this.outParamType = outParamType; - this.inParamType = inParamType; + this.inParamType = Arrays.asList(inParamType); } public RedisCommand(String name, MultiDecoder replayMultiDecoder) { @@ -146,7 +176,7 @@ public class RedisCommand { return paramsEncoder; } - public ValueType getInParamType() { + public List getInParamType() { return inParamType; } diff --git a/src/main/java/org/redisson/client/protocol/RedisCommands.java b/src/main/java/org/redisson/client/protocol/RedisCommands.java index f095afc9c..deee6857b 100644 --- a/src/main/java/org/redisson/client/protocol/RedisCommands.java +++ b/src/main/java/org/redisson/client/protocol/RedisCommands.java @@ -19,8 +19,9 @@ import java.util.List; import java.util.Map; import org.redisson.client.protocol.RedisCommand.ValueType; -import org.redisson.client.protocol.decoder.BooleanReplayDecoder; +import org.redisson.client.protocol.decoder.BooleanStatusReplayDecoder; import org.redisson.client.protocol.decoder.KeyValueObjectDecoder; +import org.redisson.client.protocol.decoder.MapScanResultReplayDecoder; import org.redisson.client.protocol.decoder.ObjectListReplayDecoder; import org.redisson.client.protocol.decoder.ObjectMapReplayDecoder; import org.redisson.client.protocol.decoder.StringDataDecoder; @@ -30,6 +31,8 @@ import org.redisson.client.protocol.decoder.StringReplayDecoder; import org.redisson.client.protocol.pubsub.PubSubStatusDecoder; import org.redisson.client.protocol.pubsub.PubSubStatusMessage; +import com.lambdaworks.redis.output.MapScanResult; + public interface RedisCommands { RedisCommand LPOP = new RedisCommand("LPOP"); @@ -50,7 +53,7 @@ public interface RedisCommands { RedisStrictCommand EVAL_INTEGER = new RedisStrictCommand("EVAL"); RedisCommand> EVAL_LIST = new RedisCommand>("EVAL", new ObjectListReplayDecoder()); RedisCommand EVAL_OBJECT = new RedisCommand("EVAL"); - RedisCommand EVAL_MAP_VALUE = new RedisCommand("EVAL", ValueType.MAP_VALUE); + RedisCommand EVAL_MAP_VALUE = new RedisCommand("EVAL", 4, ValueType.MAP, ValueType.MAP_VALUE); RedisStrictCommand INCR = new RedisStrictCommand("INCR"); RedisStrictCommand INCRBY = new RedisStrictCommand("INCRBY"); @@ -64,24 +67,27 @@ public interface RedisCommands { RedisStrictCommand> KEYS = new RedisStrictCommand>("KEYS", new StringListReplayDecoder()); + RedisStrictCommand HINCRBYFLOAT = new RedisStrictCommand("HINCRBYFLOAT"); + RedisCommand> HSCAN = new RedisCommand>("HSCAN", new MapScanResultReplayDecoder(), ValueType.MAP); RedisCommand> HGETALL = new RedisCommand>("HGETALL", new ObjectMapReplayDecoder(), ValueType.MAP); RedisCommand> HVALS = new RedisCommand>("HVALS", new ObjectListReplayDecoder(), ValueType.MAP_VALUE); - RedisCommand HEXISTS = new RedisCommand("HEXISTS", new BooleanReplayConvertor(), 1, ValueType.MAP_KEY); + RedisCommand HEXISTS = new RedisCommand("HEXISTS", new BooleanReplayConvertor(), 2, ValueType.MAP_KEY); RedisStrictCommand HLEN = new RedisStrictCommand("HLEN"); RedisCommand> HKEYS = new RedisCommand>("HKEYS", new ObjectListReplayDecoder(), ValueType.MAP_KEY); RedisCommand HMSET = new RedisCommand("HMSET", new StringReplayDecoder(), 1, ValueType.MAP); - RedisCommand> HMGET = new RedisCommand>("HMGET", new ObjectListReplayDecoder(), 1, ValueType.MAP_KEY, ValueType.MAP_VALUE); - RedisCommand HGET = new RedisCommand("HGET", 1, ValueType.MAP_KEY, ValueType.MAP_VALUE); + RedisCommand> HMGET = new RedisCommand>("HMGET", new ObjectListReplayDecoder(), 2, ValueType.MAP_KEY, ValueType.MAP_VALUE); + RedisCommand HGET = new RedisCommand("HGET", 2, ValueType.MAP_KEY, ValueType.MAP_VALUE); + RedisCommand HDEL = new RedisStrictCommand("HDEL", 2, ValueType.MAP_KEY); RedisStrictCommand DEL_BOOLEAN = new RedisStrictCommand("DEL", new BooleanReplayConvertor()); RedisCommand GET = new RedisCommand("GET"); - RedisCommand SET = new RedisCommand("SET", new StringReplayDecoder(), 1); + RedisCommand SET = new RedisCommand("SET", new StringReplayDecoder(), 2); RedisCommand SETEX = new RedisCommand("SETEX", new StringReplayDecoder(), 2); RedisStrictCommand EXISTS = new RedisStrictCommand("EXISTS", new BooleanReplayConvertor()); RedisStrictCommand RENAMENX = new RedisStrictCommand("RENAMENX", new BooleanReplayConvertor()); - RedisStrictCommand RENAME = new RedisStrictCommand("RENAME", new BooleanReplayDecoder()); + RedisStrictCommand RENAME = new RedisStrictCommand("RENAME", new BooleanStatusReplayDecoder()); RedisCommand PUBLISH = new RedisCommand("PUBLISH", 1); diff --git a/src/main/java/org/redisson/client/protocol/RedisStrictCommand.java b/src/main/java/org/redisson/client/protocol/RedisStrictCommand.java index c98653c21..192007855 100644 --- a/src/main/java/org/redisson/client/protocol/RedisStrictCommand.java +++ b/src/main/java/org/redisson/client/protocol/RedisStrictCommand.java @@ -15,10 +15,14 @@ */ package org.redisson.client.protocol; -import org.redisson.client.protocol.pubsub.MultiDecoder; +import org.redisson.client.protocol.decoder.MultiDecoder; public class RedisStrictCommand extends RedisCommand { + public RedisStrictCommand(String name, int objectParamIndex, ValueType inParamType) { + super(name, (Decoder)null, objectParamIndex, inParamType); + } + public RedisStrictCommand(String name, MultiDecoder replayMultiDecoder) { super(name, replayMultiDecoder); } diff --git a/src/main/java/org/redisson/client/protocol/decoder/BooleanReplayDecoder2.java b/src/main/java/org/redisson/client/protocol/decoder/BooleanReplayDecoder2.java new file mode 100644 index 000000000..b4f9281ec --- /dev/null +++ b/src/main/java/org/redisson/client/protocol/decoder/BooleanReplayDecoder2.java @@ -0,0 +1,18 @@ +package org.redisson.client.protocol.decoder; + +import org.redisson.client.protocol.Decoder; + +import io.netty.buffer.ByteBuf; +import io.netty.util.CharsetUtil; + +public class BooleanReplayDecoder2 implements Decoder { + + @Override + public Boolean decode(ByteBuf buf) { + if (buf == null) { + return false; + } + return "OK".equals(buf.toString(CharsetUtil.UTF_8)); + } + +} diff --git a/src/main/java/org/redisson/client/protocol/decoder/BooleanReplayDecoder.java b/src/main/java/org/redisson/client/protocol/decoder/BooleanStatusReplayDecoder.java similarity index 84% rename from src/main/java/org/redisson/client/protocol/decoder/BooleanReplayDecoder.java rename to src/main/java/org/redisson/client/protocol/decoder/BooleanStatusReplayDecoder.java index 93ad4ef23..5d7777341 100644 --- a/src/main/java/org/redisson/client/protocol/decoder/BooleanReplayDecoder.java +++ b/src/main/java/org/redisson/client/protocol/decoder/BooleanStatusReplayDecoder.java @@ -5,7 +5,7 @@ import org.redisson.client.protocol.Decoder; import io.netty.buffer.ByteBuf; import io.netty.util.CharsetUtil; -public class BooleanReplayDecoder implements Decoder { +public class BooleanStatusReplayDecoder implements Decoder { @Override public Boolean decode(ByteBuf buf) { diff --git a/src/main/java/org/redisson/client/protocol/decoder/KeyValueObjectDecoder.java b/src/main/java/org/redisson/client/protocol/decoder/KeyValueObjectDecoder.java index 51f07c8e9..d6c1b4b56 100644 --- a/src/main/java/org/redisson/client/protocol/decoder/KeyValueObjectDecoder.java +++ b/src/main/java/org/redisson/client/protocol/decoder/KeyValueObjectDecoder.java @@ -2,13 +2,15 @@ package org.redisson.client.protocol.decoder; import java.util.List; -import org.redisson.client.protocol.pubsub.MultiDecoder; - import io.netty.buffer.ByteBuf; import io.netty.util.CharsetUtil; public class KeyValueObjectDecoder implements MultiDecoder { + public MultiDecoder get() { + return (MultiDecoder) this; + } + @Override public Object decode(ByteBuf buf) { String status = buf.toString(CharsetUtil.UTF_8); diff --git a/src/main/java/org/redisson/client/protocol/decoder/LongReplayDecoder.java b/src/main/java/org/redisson/client/protocol/decoder/LongReplayDecoder.java new file mode 100644 index 000000000..17541a528 --- /dev/null +++ b/src/main/java/org/redisson/client/protocol/decoder/LongReplayDecoder.java @@ -0,0 +1,18 @@ +package org.redisson.client.protocol.decoder; + +import org.redisson.client.protocol.Decoder; + +import io.netty.buffer.ByteBuf; +import io.netty.util.CharsetUtil; + +public class LongReplayDecoder implements Decoder { + + @Override + public Long decode(ByteBuf buf) { + if (buf == null) { + return 0L; + } + return Long.valueOf(buf.toString(CharsetUtil.UTF_8)); + } + +} diff --git a/src/main/java/org/redisson/client/protocol/decoder/MapScanResultReplayDecoder.java b/src/main/java/org/redisson/client/protocol/decoder/MapScanResultReplayDecoder.java new file mode 100644 index 000000000..807202c7d --- /dev/null +++ b/src/main/java/org/redisson/client/protocol/decoder/MapScanResultReplayDecoder.java @@ -0,0 +1,41 @@ +package org.redisson.client.protocol.decoder; + +import java.util.List; +import java.util.Map; + +import com.lambdaworks.redis.output.MapScanResult; + +import io.netty.buffer.ByteBuf; +import io.netty.util.CharsetUtil; + +public class MapScanResultReplayDecoder implements MultiDecoder> { + + ThreadLocal> currentMultiDecoder = new ThreadLocal>(); + ThreadLocal posParsed = new ThreadLocal(); + ObjectMapReplayDecoder nextDecoder = new ObjectMapReplayDecoder(); + + public MultiDecoder get() { + if (currentMultiDecoder.get() == null) { + currentMultiDecoder.set(nextDecoder); + return nextDecoder; + } + return (MultiDecoder) this; + } + + @Override + public Object decode(ByteBuf buf) { + posParsed.set(true); + return Long.valueOf(buf.toString(CharsetUtil.UTF_8)); + } + + @Override + public MapScanResult decode(List parts) { + return new MapScanResult((Long)parts.get(0), (Map)parts.get(1)); + } + + @Override + public boolean isApplicable(int paramNum) { + return paramNum == 0 && posParsed.get() == null; + } + +} diff --git a/src/main/java/org/redisson/client/protocol/pubsub/MultiDecoder.java b/src/main/java/org/redisson/client/protocol/decoder/MultiDecoder.java similarity index 91% rename from src/main/java/org/redisson/client/protocol/pubsub/MultiDecoder.java rename to src/main/java/org/redisson/client/protocol/decoder/MultiDecoder.java index 2b5900316..0ee02b2b1 100644 --- a/src/main/java/org/redisson/client/protocol/pubsub/MultiDecoder.java +++ b/src/main/java/org/redisson/client/protocol/decoder/MultiDecoder.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.redisson.client.protocol.pubsub; +package org.redisson.client.protocol.decoder; import java.util.List; @@ -21,6 +21,8 @@ import org.redisson.client.protocol.Decoder; public interface MultiDecoder extends Decoder { + MultiDecoder get(); + boolean isApplicable(int paramNum); T decode(List parts); diff --git a/src/main/java/org/redisson/client/protocol/decoder/ObjectListReplayDecoder.java b/src/main/java/org/redisson/client/protocol/decoder/ObjectListReplayDecoder.java index d052c1ac1..80ab0caf9 100644 --- a/src/main/java/org/redisson/client/protocol/decoder/ObjectListReplayDecoder.java +++ b/src/main/java/org/redisson/client/protocol/decoder/ObjectListReplayDecoder.java @@ -2,8 +2,6 @@ package org.redisson.client.protocol.decoder; import java.util.List; -import org.redisson.client.protocol.pubsub.MultiDecoder; - import io.netty.buffer.ByteBuf; public class ObjectListReplayDecoder implements MultiDecoder> { @@ -23,4 +21,9 @@ public class ObjectListReplayDecoder implements MultiDecoder> { return false; } + @Override + public MultiDecoder get() { + return this; + } + } diff --git a/src/main/java/org/redisson/client/protocol/decoder/ObjectMapReplayDecoder.java b/src/main/java/org/redisson/client/protocol/decoder/ObjectMapReplayDecoder.java index cea6185bd..7788f3aa3 100644 --- a/src/main/java/org/redisson/client/protocol/decoder/ObjectMapReplayDecoder.java +++ b/src/main/java/org/redisson/client/protocol/decoder/ObjectMapReplayDecoder.java @@ -4,12 +4,15 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.redisson.client.protocol.pubsub.MultiDecoder; - import io.netty.buffer.ByteBuf; public class ObjectMapReplayDecoder implements MultiDecoder> { + @Override + public MultiDecoder get() { + return this; + } + @Override public Object decode(ByteBuf buf) { throw new UnsupportedOperationException(); @@ -20,7 +23,7 @@ public class ObjectMapReplayDecoder implements MultiDecoder> Map result = new HashMap(parts.size()/2); for (int i = 0; i < parts.size(); i++) { if (i % 2 != 0) { - result.put(parts.get(i-1).toString(), parts.get(i).toString()); + result.put(parts.get(i-1), parts.get(i)); } } return result; diff --git a/src/main/java/org/redisson/client/protocol/decoder/StringListReplayDecoder.java b/src/main/java/org/redisson/client/protocol/decoder/StringListReplayDecoder.java index bcaed6f46..ef852e38b 100644 --- a/src/main/java/org/redisson/client/protocol/decoder/StringListReplayDecoder.java +++ b/src/main/java/org/redisson/client/protocol/decoder/StringListReplayDecoder.java @@ -3,13 +3,16 @@ package org.redisson.client.protocol.decoder; import java.util.Arrays; import java.util.List; -import org.redisson.client.protocol.pubsub.MultiDecoder; - import io.netty.buffer.ByteBuf; import io.netty.util.CharsetUtil; public class StringListReplayDecoder implements MultiDecoder> { + @Override + public MultiDecoder get() { + return this; + } + @Override public Object decode(ByteBuf buf) { return buf.toString(CharsetUtil.UTF_8); diff --git a/src/main/java/org/redisson/client/protocol/decoder/StringMapReplayDecoder.java b/src/main/java/org/redisson/client/protocol/decoder/StringMapReplayDecoder.java index 8058d868d..f39b96d93 100644 --- a/src/main/java/org/redisson/client/protocol/decoder/StringMapReplayDecoder.java +++ b/src/main/java/org/redisson/client/protocol/decoder/StringMapReplayDecoder.java @@ -6,13 +6,16 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.redisson.client.protocol.pubsub.MultiDecoder; - import io.netty.buffer.ByteBuf; import io.netty.util.CharsetUtil; public class StringMapReplayDecoder implements MultiDecoder>> { + @Override + public MultiDecoder get() { + return this; + } + @Override public Object decode(ByteBuf buf) { return buf.toString(CharsetUtil.UTF_8); @@ -20,6 +23,7 @@ public class StringMapReplayDecoder implements MultiDecoder> decode(List parts) { + // TODO refactor if (!parts.isEmpty()) { if (parts.get(0) instanceof List) { List> result = new ArrayList>(parts.size()); diff --git a/src/main/java/org/redisson/client/protocol/pubsub/PubSubMessageDecoder.java b/src/main/java/org/redisson/client/protocol/pubsub/PubSubMessageDecoder.java index 03eabe831..b408da713 100644 --- a/src/main/java/org/redisson/client/protocol/pubsub/PubSubMessageDecoder.java +++ b/src/main/java/org/redisson/client/protocol/pubsub/PubSubMessageDecoder.java @@ -17,6 +17,8 @@ package org.redisson.client.protocol.pubsub; import java.util.List; +import org.redisson.client.protocol.decoder.MultiDecoder; + import io.netty.buffer.ByteBuf; import io.netty.util.CharsetUtil; @@ -39,4 +41,9 @@ public class PubSubMessageDecoder implements MultiDecoder { return true; } + @Override + public MultiDecoder get() { + return this; + } + } diff --git a/src/main/java/org/redisson/client/protocol/pubsub/PubSubPatternMessageDecoder.java b/src/main/java/org/redisson/client/protocol/pubsub/PubSubPatternMessageDecoder.java index 4440c5456..18787b997 100644 --- a/src/main/java/org/redisson/client/protocol/pubsub/PubSubPatternMessageDecoder.java +++ b/src/main/java/org/redisson/client/protocol/pubsub/PubSubPatternMessageDecoder.java @@ -17,6 +17,8 @@ package org.redisson.client.protocol.pubsub; import java.util.List; +import org.redisson.client.protocol.decoder.MultiDecoder; + import io.netty.buffer.ByteBuf; import io.netty.util.CharsetUtil; @@ -39,4 +41,9 @@ public class PubSubPatternMessageDecoder implements MultiDecoder { return true; } + @Override + public MultiDecoder get() { + return this; + } + } diff --git a/src/main/java/org/redisson/client/protocol/pubsub/PubSubStatusDecoder.java b/src/main/java/org/redisson/client/protocol/pubsub/PubSubStatusDecoder.java index b700a6806..5d4b115a8 100644 --- a/src/main/java/org/redisson/client/protocol/pubsub/PubSubStatusDecoder.java +++ b/src/main/java/org/redisson/client/protocol/pubsub/PubSubStatusDecoder.java @@ -18,6 +18,8 @@ package org.redisson.client.protocol.pubsub; import java.util.ArrayList; import java.util.List; +import org.redisson.client.protocol.decoder.MultiDecoder; + import io.netty.buffer.ByteBuf; import io.netty.util.CharsetUtil; @@ -44,4 +46,9 @@ public class PubSubStatusDecoder implements MultiDecoder { return true; } + @Override + public MultiDecoder get() { + return this; + } + }