diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/cql/QueryOptions.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/cql/QueryOptions.java index db955ebdc..7982c91b9 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/cql/QueryOptions.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/cql/QueryOptions.java @@ -219,12 +219,10 @@ public boolean equals(@Nullable Object o) { return true; } - if (!(o instanceof QueryOptions)) { + if (!(o instanceof QueryOptions options)) { return false; } - QueryOptions options = (QueryOptions) o; - if (!ObjectUtils.nullSafeEquals(consistencyLevel, options.consistencyLevel)) { return false; } @@ -482,12 +480,7 @@ public QueryOptionsBuilder readTimeout(long readTimeout, TimeUnit timeUnit) { */ @Deprecated public QueryOptionsBuilder readTimeout(Duration readTimeout) { - - Assert.isTrue(!readTimeout.isNegative(), "ReadTimeout must be greater than equal to zero"); - - this.timeout = readTimeout; - - return this; + return timeout(readTimeout); } /** diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/cql/QueryOptionsUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/cql/QueryOptionsUnitTests.java index 35cdba1b1..928f90a7b 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/cql/QueryOptionsUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/cql/QueryOptionsUnitTests.java @@ -99,22 +99,7 @@ void buildZeroDurationTimeoutQueryOptions() { @Test // GH-1494 void shouldRejectNegativeDurationTimeoutQueryOptions() { - assertThatIllegalArgumentException().isThrownBy( - () -> QueryOptions.builder().timeout(Duration.ofSeconds(-1)).build()); - } - - @Test // GH-1494 - void buildZeroDurationReadTimeoutQueryOptions() { - - QueryOptions queryOptions = QueryOptions.builder().readTimeout(Duration.ofSeconds(0)).build(); - - assertThat(queryOptions.getReadTimeout()).isEqualTo(Duration.ZERO); - } - - @Test // GH-1494 - void shouldRejectNegativeDurationReadTimeoutQueryOptions() { - - assertThatIllegalArgumentException().isThrownBy( - () -> QueryOptions.builder().readTimeout(Duration.ofSeconds(-1)).build()); + assertThatIllegalArgumentException() + .isThrownBy(() -> QueryOptions.builder().timeout(Duration.ofSeconds(-1)).build()); } }