File tree 2 files changed +11
-7
lines changed
spring-data-cassandra/src
main/java/org/springframework/data/cassandra/core/cql
test/java/org/springframework/data/cassandra/core/cql
2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -153,6 +153,7 @@ public int hashCode() {
153
153
* @author Mark Paluch
154
154
* @author Lukasz Antoniak
155
155
* @author Thomas Strauß
156
+ * @author Tudor Marc
156
157
* @since 1.5
157
158
*/
158
159
public static class WriteOptionsBuilder extends QueryOptionsBuilder {
@@ -341,7 +342,7 @@ public WriteOptionsBuilder ttl(int ttl) {
341
342
public WriteOptionsBuilder ttl (Duration ttl ) {
342
343
343
344
Assert .notNull (ttl , "TTL must not be null" );
344
- Assert .isTrue (!ttl .isNegative () && ! ttl . isZero () , "TTL must be greater than equal to zero" );
345
+ Assert .isTrue (!ttl .isNegative (), "TTL must be greater than equal to zero" );
345
346
346
347
this .ttl = ttl ;
347
348
Original file line number Diff line number Diff line change 35
35
* @author Mark Paluch
36
36
* @author Sam Lightfoot
37
37
* @author Thomas Strauß
38
+ * @author Tudor Marc
38
39
*/
39
40
class WriteOptionsUnitTests {
40
41
@@ -107,16 +108,18 @@ void buildWriteOptionsMutate() {
107
108
assertThat (writeOptions .getRoutingKey ()).isEqualTo (ByteBuffer .allocate (1 ));
108
109
}
109
110
110
- @ Test // GH-1248
111
- void buildWriteOptionsWithTtlDurationZero () {
112
- assertThatIllegalArgumentException ().isThrownBy (() -> WriteOptions .builder ().ttl (0 ));
113
- assertThatIllegalArgumentException ().isThrownBy (() -> WriteOptions .builder ().ttl (Duration .ZERO ));
114
- }
115
-
116
111
@ Test // GH-1248
117
112
void buildWriteOptionsWithTtlNegativeDuration () {
118
113
assertThatIllegalArgumentException ().isThrownBy (() -> WriteOptions .builder ().ttl (-1 ));
119
114
assertThatIllegalArgumentException ()
120
115
.isThrownBy (() -> WriteOptions .builder ().ttl (Duration .of (-1 , ChronoUnit .MICROS )));
121
116
}
117
+
118
+ @ Test // GH-1262
119
+ void buildZeroDurationTtlWriterOptions () {
120
+
121
+ WriteOptions writeOptions = WriteOptions .builder ().ttl (0 ).build ();
122
+
123
+ assertThat (writeOptions .getTtl ()).isEqualTo (Duration .ZERO );
124
+ }
122
125
}
You can’t perform that action at this time.
0 commit comments