Skip to content

Commit 0b69a4c

Browse files
committed
Annotate BatchStatement methods with CheckReturnValue
Since the driver's default implementation is for BatchStatement methods to be immutable, we should annotate those methods with @CheckReturnValue
1 parent 741df6f commit 0b69a4c

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

core/revapi.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6824,6 +6824,55 @@
68246824
"new": "class com.datastax.oss.driver.api.core.type.codec.CodecNotFoundException",
68256825
"superClass": "com.datastax.oss.driver.api.core.DriverException",
68266826
"justification": "Make CodecNotFoundException to extend DriverException as all other driver exceptions do"
6827+
},
6828+
{
6829+
"code": "java.annotation.added",
6830+
"old": "method com.datastax.oss.driver.api.core.cql.BatchStatement com.datastax.oss.driver.api.core.cql.BatchStatement::add(com.datastax.oss.driver.api.core.cql.BatchableStatement<?>)",
6831+
"new": "method com.datastax.oss.driver.api.core.cql.BatchStatement com.datastax.oss.driver.api.core.cql.BatchStatement::add(com.datastax.oss.driver.api.core.cql.BatchableStatement<?>)",
6832+
"annotation": "@edu.umd.cs.findbugs.annotations.CheckReturnValue",
6833+
"justification": "Annotate mutating methods with @CheckReturnValue"
6834+
},
6835+
{
6836+
"code": "java.annotation.added",
6837+
"old": "method com.datastax.oss.driver.api.core.cql.BatchStatement com.datastax.oss.driver.api.core.cql.BatchStatement::addAll(com.datastax.oss.driver.api.core.cql.BatchableStatement<?>[])",
6838+
"new": "method com.datastax.oss.driver.api.core.cql.BatchStatement com.datastax.oss.driver.api.core.cql.BatchStatement::addAll(com.datastax.oss.driver.api.core.cql.BatchableStatement<?>[])",
6839+
"annotation": "@edu.umd.cs.findbugs.annotations.CheckReturnValue",
6840+
"justification": "Annotate mutating methods with @CheckReturnValue"
6841+
},
6842+
{
6843+
"code": "java.annotation.added",
6844+
"old": "method com.datastax.oss.driver.api.core.cql.BatchStatement com.datastax.oss.driver.api.core.cql.BatchStatement::addAll(java.lang.Iterable<? extends com.datastax.oss.driver.api.core.cql.BatchableStatement<?>>)",
6845+
"new": "method com.datastax.oss.driver.api.core.cql.BatchStatement com.datastax.oss.driver.api.core.cql.BatchStatement::addAll(java.lang.Iterable<? extends com.datastax.oss.driver.api.core.cql.BatchableStatement<?>>)",
6846+
"annotation": "@edu.umd.cs.findbugs.annotations.CheckReturnValue",
6847+
"justification": "Annotate mutating methods with @CheckReturnValue"
6848+
},
6849+
{
6850+
"code": "java.annotation.added",
6851+
"old": "method com.datastax.oss.driver.api.core.cql.BatchStatement com.datastax.oss.driver.api.core.cql.BatchStatement::clear()",
6852+
"new": "method com.datastax.oss.driver.api.core.cql.BatchStatement com.datastax.oss.driver.api.core.cql.BatchStatement::clear()",
6853+
"annotation": "@edu.umd.cs.findbugs.annotations.CheckReturnValue",
6854+
"justification": "Annotate mutating methods with @CheckReturnValue"
6855+
},
6856+
{
6857+
"code": "java.annotation.added",
6858+
"old": "method com.datastax.oss.driver.api.core.cql.BatchStatement com.datastax.oss.driver.api.core.cql.BatchStatement::setBatchType(com.datastax.oss.driver.api.core.cql.BatchType)",
6859+
"new": "method com.datastax.oss.driver.api.core.cql.BatchStatement com.datastax.oss.driver.api.core.cql.BatchStatement::setBatchType(com.datastax.oss.driver.api.core.cql.BatchType)",
6860+
"annotation": "@edu.umd.cs.findbugs.annotations.CheckReturnValue",
6861+
"justification": "Annotate mutating methods with @CheckReturnValue"
6862+
},
6863+
{
6864+
"code": "java.annotation.added",
6865+
"old": "method com.datastax.oss.driver.api.core.cql.BatchStatement com.datastax.oss.driver.api.core.cql.BatchStatement::setKeyspace(com.datastax.oss.driver.api.core.CqlIdentifier)",
6866+
"new": "method com.datastax.oss.driver.api.core.cql.BatchStatement com.datastax.oss.driver.api.core.cql.BatchStatement::setKeyspace(com.datastax.oss.driver.api.core.CqlIdentifier)",
6867+
"annotation": "@edu.umd.cs.findbugs.annotations.CheckReturnValue",
6868+
"justification": "JAVA-2161: Annotate mutating methods with @CheckReturnValue"
6869+
},
6870+
{
6871+
"code": "java.annotation.added",
6872+
"old": "method com.datastax.oss.driver.api.core.cql.BatchStatement com.datastax.oss.driver.api.core.cql.BatchStatement::setKeyspace(java.lang.String)",
6873+
"new": "method com.datastax.oss.driver.api.core.cql.BatchStatement com.datastax.oss.driver.api.core.cql.BatchStatement::setKeyspace(java.lang.String)",
6874+
"annotation": "@edu.umd.cs.findbugs.annotations.CheckReturnValue",
6875+
"justification": "JAVA-2161: Annotate mutating methods with @CheckReturnValue"
68276876
}
68286877
]
68296878
}

core/src/main/java/com/datastax/oss/driver/api/core/cql/BatchStatement.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.datastax.oss.driver.internal.core.util.Sizes;
2525
import com.datastax.oss.driver.shaded.guava.common.collect.ImmutableList;
2626
import com.datastax.oss.protocol.internal.PrimitiveSizes;
27+
import edu.umd.cs.findbugs.annotations.CheckReturnValue;
2728
import edu.umd.cs.findbugs.annotations.NonNull;
2829
import edu.umd.cs.findbugs.annotations.Nullable;
2930
import java.util.ArrayList;
@@ -162,6 +163,7 @@ static BatchStatementBuilder builder(@NonNull BatchStatement template) {
162163
* method. However custom implementations may choose to be mutable and return the same instance.
163164
*/
164165
@NonNull
166+
@CheckReturnValue
165167
BatchStatement setBatchType(@NonNull BatchType newBatchType);
166168

167169
/**
@@ -178,13 +180,15 @@ static BatchStatementBuilder builder(@NonNull BatchStatement template) {
178180
* @see Request#getKeyspace()
179181
*/
180182
@NonNull
183+
@CheckReturnValue
181184
BatchStatement setKeyspace(@Nullable CqlIdentifier newKeyspace);
182185

183186
/**
184187
* Shortcut for {@link #setKeyspace(CqlIdentifier)
185188
* setKeyspace(CqlIdentifier.fromCql(newKeyspaceName))}.
186189
*/
187190
@NonNull
191+
@CheckReturnValue
188192
default BatchStatement setKeyspace(@NonNull String newKeyspaceName) {
189193
return setKeyspace(CqlIdentifier.fromCql(newKeyspaceName));
190194
}
@@ -199,6 +203,7 @@ default BatchStatement setKeyspace(@NonNull String newKeyspaceName) {
199203
* method. However custom implementations may choose to be mutable and return the same instance.
200204
*/
201205
@NonNull
206+
@CheckReturnValue
202207
BatchStatement add(@NonNull BatchableStatement<?> statement);
203208

204209
/**
@@ -211,10 +216,12 @@ default BatchStatement setKeyspace(@NonNull String newKeyspaceName) {
211216
* method. However custom implementations may choose to be mutable and return the same instance.
212217
*/
213218
@NonNull
219+
@CheckReturnValue
214220
BatchStatement addAll(@NonNull Iterable<? extends BatchableStatement<?>> statements);
215221

216222
/** @see #addAll(Iterable) */
217223
@NonNull
224+
@CheckReturnValue
218225
default BatchStatement addAll(@NonNull BatchableStatement<?>... statements) {
219226
return addAll(Arrays.asList(statements));
220227
}
@@ -229,6 +236,7 @@ default BatchStatement addAll(@NonNull BatchableStatement<?>... statements) {
229236
* method. However custom implementations may choose to be mutable and return the same instance.
230237
*/
231238
@NonNull
239+
@CheckReturnValue
232240
BatchStatement clear();
233241

234242
@Override

0 commit comments

Comments
 (0)