From b4a90abb7558b50ab41642ee9d20fc4391c0fea7 Mon Sep 17 00:00:00 2001 From: "xiaofan.chen" Date: Thu, 8 Aug 2024 13:47:34 +0800 Subject: [PATCH] chore: add asserts, revert jetbrain#NotNull --- src/main/java/io/lettuce/core/AutoBatchFlushOptions.java | 6 ++++++ src/main/java/io/lettuce/core/ContextualChannel.java | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/lettuce/core/AutoBatchFlushOptions.java b/src/main/java/io/lettuce/core/AutoBatchFlushOptions.java index 35ea9e0ed3..7c61c1d04a 100644 --- a/src/main/java/io/lettuce/core/AutoBatchFlushOptions.java +++ b/src/main/java/io/lettuce/core/AutoBatchFlushOptions.java @@ -2,6 +2,8 @@ import java.io.Serializable; +import io.lettuce.core.internal.LettuceAssert; + /** * Options for command timeouts. These options configure how and whether commands time out once they were dispatched. Command * timeout begins: @@ -79,6 +81,8 @@ public Builder enableAutoBatchFlush(boolean enableAutoBatchFlush) { * @return {@code this} */ public Builder writeSpinCount(int writeSpinCount) { + LettuceAssert.isPositive(writeSpinCount, "Batch size must be greater than 0"); + this.writeSpinCount = writeSpinCount; return this; } @@ -90,6 +94,8 @@ public Builder writeSpinCount(int writeSpinCount) { * @return {@code this} */ public Builder batchSize(int batchSize) { + LettuceAssert.isPositive(batchSize, "Batch size must be greater than 0"); + this.batchSize = batchSize; return this; } diff --git a/src/main/java/io/lettuce/core/ContextualChannel.java b/src/main/java/io/lettuce/core/ContextualChannel.java index f01c88bee1..188698e0cf 100644 --- a/src/main/java/io/lettuce/core/ContextualChannel.java +++ b/src/main/java/io/lettuce/core/ContextualChannel.java @@ -2,6 +2,8 @@ import java.net.SocketAddress; +import javax.annotation.Nonnull; + import io.lettuce.core.context.ConnectionContext; import io.netty.buffer.ByteBufAllocator; import io.netty.channel.Channel; @@ -15,7 +17,6 @@ import io.netty.channel.EventLoop; import io.netty.util.Attribute; import io.netty.util.AttributeKey; -import org.jetbrains.annotations.NotNull; /** * @author chenxiaofan @@ -250,7 +251,7 @@ public boolean hasAttr(AttributeKey attributeKey) { } @Override - public int compareTo(@NotNull Channel o) { + public int compareTo(@Nonnull Channel o) { return this == o ? 0 : this.id().compareTo(o.id()); }