From c63a659856a26187486e6b22cbc0bf47ba7ffc7d Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Wed, 20 Feb 2019 15:19:29 +0300 Subject: [PATCH] refactoring --- .../client/handler/CommandDecoder.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/redisson/src/main/java/org/redisson/client/handler/CommandDecoder.java b/redisson/src/main/java/org/redisson/client/handler/CommandDecoder.java index c9ef09048..2fc915451 100644 --- a/redisson/src/main/java/org/redisson/client/handler/CommandDecoder.java +++ b/redisson/src/main/java/org/redisson/client/handler/CommandDecoder.java @@ -115,25 +115,18 @@ public class CommandDecoder extends ReplayingDecoder { decode(ctx, in, data); } } else { - in.markReaderIndex(); - if (data instanceof CommandsData) { - CommandsData cmd = (CommandsData) data; - if (!cmd.isSkipResult()) { - for (int j = 0; j < cmd.getCommands().size(); j++) { - skipCommand(in); - } - } - } else { + if (!(data instanceof CommandsData)) { + in.markReaderIndex(); skipCommand(in); + in.resetReaderIndex(); } - in.resetReaderIndex(); decode(ctx, in, data); } } private void decode(ChannelHandlerContext ctx, ByteBuf in, QueueCommand data) throws Exception { - if (decodeInExecutor) { + if (decodeInExecutor && !(data instanceof CommandsData)) { ByteBuf copy = in.copy(in.readerIndex(), in.writerIndex() - in.readerIndex()); in.skipBytes(in.writerIndex() - in.readerIndex()); executor.execute(() -> { @@ -251,7 +244,13 @@ public class CommandDecoder extends ReplayingDecoder { while (in.writerIndex() > in.readerIndex()) { CommandData commandData = null; try { + checkpoint(); state.get().setBatchIndex(i); + + in.markReaderIndex(); + skipCommand(in); + in.resetReaderIndex(); + RedisCommand cmd = commandBatch.getCommands().get(i).getCommand(); boolean skipConvertor = commandBatch.isQueued(); List> commandsData = null; @@ -317,6 +316,7 @@ public class CommandDecoder extends ReplayingDecoder { sendNext(channel); } else { + checkpoint(); state.get().setBatchIndex(i); } }