refactoring

2.x.x
Nikita Koksharov 6 years ago
parent f82246c345
commit 5e56c4f977

@ -272,21 +272,15 @@ public class CommandDecoder extends ReplayingDecoder<State> {
int code = in.readByte(); int code = in.readByte();
Channel channel = ctx.channel(); Channel channel = ctx.channel();
if (code == '+') { if (code == '+') {
ByteBuf rb = in.readBytes(in.bytesBefore((byte) '\r')); int len = in.bytesBefore((byte) '\r');
try { String result = in.toString(in.readerIndex(), len, CharsetUtil.UTF_8);
String result = rb.toString(CharsetUtil.UTF_8); in.skipBytes(len + 2);
in.skipBytes(2);
handleResult(data, parts, result, skipConvertor, channel); handleResult(data, parts, result, skipConvertor, channel);
} finally {
rb.release();
}
} else if (code == '-') { } else if (code == '-') {
ByteBuf rb = in.readBytes(in.bytesBefore((byte) '\r')); int len = in.bytesBefore((byte) '\r');
try { String error = in.toString(in.readerIndex(), len, CharsetUtil.UTF_8);
String error = rb.toString(CharsetUtil.UTF_8); in.skipBytes(len + 2);
in.skipBytes(2);
if (error.startsWith("MOVED")) { if (error.startsWith("MOVED")) {
String[] errorParts = error.split(" "); String[] errorParts = error.split(" ");
int slot = Integer.valueOf(errorParts[1]); int slot = Integer.valueOf(errorParts[1]);
@ -316,9 +310,6 @@ public class CommandDecoder extends ReplayingDecoder<State> {
log.error("Error message from Redis: {} channel: {}", error, channel); log.error("Error message from Redis: {} channel: {}", error, channel);
} }
} }
} finally {
rb.release();
}
} else if (code == ':') { } else if (code == ':') {
Long result = readLong(in); Long result = readLong(in);
handleResult(data, parts, result, false, channel); handleResult(data, parts, result, false, channel);

Loading…
Cancel
Save