diff --git a/src/main/java/io/lettuce/core/protocol/RedisStateMachine.java b/src/main/java/io/lettuce/core/protocol/RedisStateMachine.java index c016474608..e7ee692f4b 100644 --- a/src/main/java/io/lettuce/core/protocol/RedisStateMachine.java +++ b/src/main/java/io/lettuce/core/protocol/RedisStateMachine.java @@ -20,7 +20,6 @@ import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; import java.util.Arrays; -import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Consumer; import io.lettuce.core.internal.LettuceStrings; @@ -205,6 +204,7 @@ public Result handle(RedisStateMachine rsm, State state, ByteBuf buffer, Command Consumer errorHandler) { return behavior.handle(rsm, state, buffer, output, errorHandler); } + } enum Result { @@ -231,8 +231,6 @@ public String toString() { private final boolean debugEnabled = logger.isDebugEnabled(); - private final AtomicBoolean closed = new AtomicBoolean(); - private final Resp2LongProcessor longProcessor = new Resp2LongProcessor(); private ProtocolVersion protocolVersion = null; @@ -241,9 +239,18 @@ public String toString() { /** * Initialize a new instance. + * + * @deprecated since 6.3, {@link ByteBufAllocator no longer required}. */ - public RedisStateMachine() { + @Deprecated + public RedisStateMachine(ByteBufAllocator alloc) { + this(); + } + /** + * Initialize a new instance. + */ + public RedisStateMachine() { } public boolean isDiscoverProtocol() { @@ -358,8 +365,8 @@ static State.Result handleSingle(RedisStateMachine rsm, State state, ByteBuf buf return State.Result.NORMAL_END; } - static State.Result handleBigNumber(RedisStateMachine rsm, State state, ByteBuf buffer, - CommandOutput output, Consumer errorHandler) { + static State.Result handleBigNumber(RedisStateMachine rsm, State state, ByteBuf buffer, CommandOutput output, + Consumer errorHandler) { ByteBuffer bytes; if ((bytes = rsm.readLine(buffer)) == null) { @@ -425,8 +432,8 @@ static State.Result handleFloat(RedisStateMachine rsm, State state, ByteBuf buff return State.Result.NORMAL_END; } - static State.Result handleBulkAndVerbatim(RedisStateMachine rsm, State state, ByteBuf buffer, - CommandOutput output, Consumer errorHandler) { + static State.Result handleBulkAndVerbatim(RedisStateMachine rsm, State state, ByteBuf buffer, CommandOutput output, + Consumer errorHandler) { int length; int end; @@ -445,8 +452,8 @@ static State.Result handleBulkAndVerbatim(RedisStateMachine rsm, State state, By return State.Result.NORMAL_END; } - static State.Result handleBulkError(RedisStateMachine rsm, State state, ByteBuf buffer, - CommandOutput output, Consumer errorHandler) { + static State.Result handleBulkError(RedisStateMachine rsm, State state, ByteBuf buffer, CommandOutput output, + Consumer errorHandler) { int length; int end; @@ -479,8 +486,8 @@ static State.Result handleHelloV3(RedisStateMachine rsm, State state, ByteBuf bu return returnDependStateCount(rsm, state); } - static State.Result handlePushAndMulti(RedisStateMachine rsm, State state, ByteBuf buffer, - CommandOutput output, Consumer errorHandler) { + static State.Result handlePushAndMulti(RedisStateMachine rsm, State state, ByteBuf buffer, CommandOutput output, + Consumer errorHandler) { int end; if (state.count == NOT_FOUND) { @@ -547,8 +554,8 @@ static State.Result returnDependStateCount(RedisStateMachine rsm, State state) { return State.Result.CONTINUE_LOOP; } - static State.Result handleVerbatim(RedisStateMachine rsm, State state, ByteBuf buffer, - CommandOutput output, Consumer errorHandler) { + static State.Result handleVerbatim(RedisStateMachine rsm, State state, ByteBuf buffer, CommandOutput output, + Consumer errorHandler) { ByteBuffer bytes; if ((bytes = rsm.readBytes(buffer, state.count)) == null) { @@ -588,9 +595,6 @@ public void reset() { * Close the state machine to free resources. */ public void close() { - if (closed.compareAndSet(false, true)) { - // free resources if any - } } private int findLineEnd(ByteBuf buffer) { @@ -671,7 +675,8 @@ private ByteBuffer readBytes(ByteBuf buffer, int count) { } private ByteBuffer readBytes0(ByteBuf buffer, int count) { - final ByteBuffer byteBuffer = buffer.internalNioBuffer(buffer.readerIndex(), count); + + ByteBuffer byteBuffer = buffer.internalNioBuffer(buffer.readerIndex(), count); // advance reader index buffer.readerIndex(buffer.readerIndex() + count);