Skip to content

Annotate BatchStatement, Statement, SimpleStatement methods with CheckReturnValue #1607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 133 additions & 0 deletions core/revapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -6956,6 +6956,139 @@
"old": "method java.lang.Throwable java.lang.Throwable::fillInStackTrace() @ com.fasterxml.jackson.databind.deser.UnresolvedForwardReference",
"new": "method com.fasterxml.jackson.databind.deser.UnresolvedForwardReference com.fasterxml.jackson.databind.deser.UnresolvedForwardReference::fillInStackTrace()",
"justification": "Upgrade jackson-databind to 2.13.4.1 to address CVEs, API change cause: https://github.com/FasterXML/jackson-databind/issues/3419"
},
{
"code": "java.annotation.added",
"old": "method SelfT com.datastax.oss.driver.api.core.cql.Statement<SelfT extends com.datastax.oss.driver.api.core.cql.Statement<SelfT>>::setNowInSeconds(int) @ com.datastax.oss.driver.api.core.cql.BatchStatement",
"new": "method SelfT com.datastax.oss.driver.api.core.cql.Statement<SelfT extends com.datastax.oss.driver.api.core.cql.Statement<SelfT>>::setNowInSeconds(int) @ com.datastax.oss.driver.api.core.cql.BatchStatement",
"annotation": "@edu.umd.cs.findbugs.annotations.CheckReturnValue",
"justification": "Annotate mutating methods with @CheckReturnValue"
},
{
"code": "java.annotation.added",
"old": "method SelfT com.datastax.oss.driver.api.core.cql.Statement<SelfT extends com.datastax.oss.driver.api.core.cql.Statement<SelfT>>::setNowInSeconds(int) @ com.datastax.oss.driver.api.core.cql.BatchableStatement<SelfT extends com.datastax.oss.driver.api.core.cql.BatchableStatement<SelfT>>",
"new": "method SelfT com.datastax.oss.driver.api.core.cql.Statement<SelfT extends com.datastax.oss.driver.api.core.cql.Statement<SelfT>>::setNowInSeconds(int) @ com.datastax.oss.driver.api.core.cql.BatchStatement",
"annotation": "@edu.umd.cs.findbugs.annotations.CheckReturnValue",
"justification": "Annotate mutating methods with @CheckReturnValue"
},
{
"code": "java.annotation.added",
"old": "method SelfT com.datastax.oss.driver.api.core.cql.Statement<SelfT extends com.datastax.oss.driver.api.core.cql.Statement<SelfT>>::setNowInSeconds(int) @ com.datastax.oss.driver.api.core.cql.BatchableStatement<SelfT extends com.datastax.oss.driver.api.core.cql.BatchableStatement<SelfT>>",
"new": "method SelfT com.datastax.oss.driver.api.core.cql.Statement<SelfT extends com.datastax.oss.driver.api.core.cql.Statement<SelfT>>::setNowInSeconds(int) @ com.datastax.oss.driver.api.core.cql.BatchableStatement<SelfT extends com.datastax.oss.driver.api.core.cql.BatchableStatement<SelfT>>",
"annotation": "@edu.umd.cs.findbugs.annotations.CheckReturnValue",
"justification": "Annotate mutating methods with @CheckReturnValue"
},
{
"code": "java.annotation.added",
"old": "method SelfT com.datastax.oss.driver.api.core.cql.Statement<SelfT extends com.datastax.oss.driver.api.core.cql.Statement<SelfT>>::setNowInSeconds(int) @ com.datastax.oss.driver.api.core.cql.BoundStatement",
"new": "method SelfT com.datastax.oss.driver.api.core.cql.Statement<SelfT extends com.datastax.oss.driver.api.core.cql.Statement<SelfT>>::setNowInSeconds(int) @ com.datastax.oss.driver.api.core.cql.BoundStatement",
"annotation": "@edu.umd.cs.findbugs.annotations.CheckReturnValue",
"justification": "Annotate mutating methods with @CheckReturnValue"
},
{
"code": "java.annotation.added",
"old": "method SelfT com.datastax.oss.driver.api.core.cql.Statement<SelfT extends com.datastax.oss.driver.api.core.cql.Statement<SelfT>>::setNowInSeconds(int) @ com.datastax.oss.driver.api.core.cql.SimpleStatement",
"new": "method SelfT com.datastax.oss.driver.api.core.cql.Statement<SelfT extends com.datastax.oss.driver.api.core.cql.Statement<SelfT>>::setNowInSeconds(int) @ com.datastax.oss.driver.api.core.cql.SimpleStatement",
"annotation": "@edu.umd.cs.findbugs.annotations.CheckReturnValue",
"justification": "Annotate mutating methods with @CheckReturnValue"
},
{
"code": "java.annotation.added",
"old": "method SelfT com.datastax.oss.driver.api.core.cql.Statement<SelfT extends com.datastax.oss.driver.api.core.cql.Statement<SelfT>>::setNowInSeconds(int)",
"new": "method SelfT com.datastax.oss.driver.api.core.cql.Statement<SelfT extends com.datastax.oss.driver.api.core.cql.Statement<SelfT>>::setNowInSeconds(int)",
"annotation": "@edu.umd.cs.findbugs.annotations.CheckReturnValue",
"justification": "Annotate mutating methods with @CheckReturnValue"
},
{
"code": "java.annotation.added",
"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<?>)",
"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<?>)",
"annotation": "@edu.umd.cs.findbugs.annotations.CheckReturnValue",
"justification": "Annotate mutating methods with @CheckReturnValue"
},
{
"code": "java.annotation.added",
"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<?>[])",
"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<?>[])",
"annotation": "@edu.umd.cs.findbugs.annotations.CheckReturnValue",
"justification": "Annotate mutating methods with @CheckReturnValue"
},
{
"code": "java.annotation.added",
"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<?>>)",
"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<?>>)",
"annotation": "@edu.umd.cs.findbugs.annotations.CheckReturnValue",
"justification": "Annotate mutating methods with @CheckReturnValue"
},
{
"code": "java.annotation.added",
"old": "method com.datastax.oss.driver.api.core.cql.BatchStatement com.datastax.oss.driver.api.core.cql.BatchStatement::clear()",
"new": "method com.datastax.oss.driver.api.core.cql.BatchStatement com.datastax.oss.driver.api.core.cql.BatchStatement::clear()",
"annotation": "@edu.umd.cs.findbugs.annotations.CheckReturnValue",
"justification": "Annotate mutating methods with @CheckReturnValue"
},
{
"code": "java.annotation.added",
"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)",
"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)",
"annotation": "@edu.umd.cs.findbugs.annotations.CheckReturnValue",
"justification": "Annotate mutating methods with @CheckReturnValue"
},
{
"code": "java.annotation.added",
"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)",
"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)",
"annotation": "@edu.umd.cs.findbugs.annotations.CheckReturnValue",
"justification": "JAVA-2161: Annotate mutating methods with @CheckReturnValue"
},
{
"code": "java.annotation.added",
"old": "method com.datastax.oss.driver.api.core.cql.BatchStatement com.datastax.oss.driver.api.core.cql.BatchStatement::setKeyspace(java.lang.String)",
"new": "method com.datastax.oss.driver.api.core.cql.BatchStatement com.datastax.oss.driver.api.core.cql.BatchStatement::setKeyspace(java.lang.String)",
"annotation": "@edu.umd.cs.findbugs.annotations.CheckReturnValue",
"justification": "JAVA-2161: Annotate mutating methods with @CheckReturnValue"
},
{
"code": "java.annotation.added",
"old": "method com.datastax.oss.driver.api.core.cql.SimpleStatement com.datastax.oss.driver.api.core.cql.SimpleStatement::setQuery(java.lang.String)",
"new": "method com.datastax.oss.driver.api.core.cql.SimpleStatement com.datastax.oss.driver.api.core.cql.SimpleStatement::setQuery(java.lang.String)",
"annotation": "@edu.umd.cs.findbugs.annotations.CheckReturnValue",
"justification": "Annotate mutating methods with @CheckReturnValue"
},
{
"code": "java.annotation.added",
"old": "method com.datastax.oss.driver.api.core.cql.SimpleStatement com.datastax.oss.driver.api.core.cql.SimpleStatement::setKeyspace(com.datastax.oss.driver.api.core.CqlIdentifier)",
"new": "method com.datastax.oss.driver.api.core.cql.SimpleStatement com.datastax.oss.driver.api.core.cql.SimpleStatement::setKeyspace(com.datastax.oss.driver.api.core.CqlIdentifier)",
"annotation": "@edu.umd.cs.findbugs.annotations.CheckReturnValue",
"justification": "Annotate mutating methods with @CheckReturnValue"
},
{
"code": "java.annotation.added",
"old": "method com.datastax.oss.driver.api.core.cql.SimpleStatement com.datastax.oss.driver.api.core.cql.SimpleStatement::setKeyspace(java.lang.String)",
"new": "method com.datastax.oss.driver.api.core.cql.SimpleStatement com.datastax.oss.driver.api.core.cql.SimpleStatement::setKeyspace(java.lang.String)",
"annotation": "@edu.umd.cs.findbugs.annotations.CheckReturnValue",
"justification": "Annotate mutating methods with @CheckReturnValue"
},
{
"code": "java.annotation.added",
"old": "method com.datastax.oss.driver.api.core.cql.SimpleStatement com.datastax.oss.driver.api.core.cql.SimpleStatement::setPositionalValues(java.util.List<java.lang.Object>)",
"new": "method com.datastax.oss.driver.api.core.cql.SimpleStatement com.datastax.oss.driver.api.core.cql.SimpleStatement::setPositionalValues(java.util.List<java.lang.Object>)",
"annotation": "@edu.umd.cs.findbugs.annotations.CheckReturnValue",
"justification": "Annotate mutating methods with @CheckReturnValue"
},
{
"code": "java.annotation.added",
"old": "method com.datastax.oss.driver.api.core.cql.SimpleStatement com.datastax.oss.driver.api.core.cql.SimpleStatement::setNamedValuesWithIds(java.util.Map<com.datastax.oss.driver.api.core.CqlIdentifier, java.lang.Object>)",
"new": "method com.datastax.oss.driver.api.core.cql.SimpleStatement com.datastax.oss.driver.api.core.cql.SimpleStatement::setNamedValuesWithIds(java.util.Map<com.datastax.oss.driver.api.core.CqlIdentifier, java.lang.Object>)",
"annotation": "@edu.umd.cs.findbugs.annotations.CheckReturnValue",
"justification": "Annotate mutating methods with @CheckReturnValue"
},
{
"code": "java.annotation.added",
"old": "method com.datastax.oss.driver.api.core.cql.SimpleStatement com.datastax.oss.driver.api.core.cql.SimpleStatement::setNamedValues(java.util.Map<java.lang.String, java.lang.Object>)",
"new": "method com.datastax.oss.driver.api.core.cql.SimpleStatement com.datastax.oss.driver.api.core.cql.SimpleStatement::setNamedValues(java.util.Map<java.lang.String, java.lang.Object>)",
"annotation": "@edu.umd.cs.findbugs.annotations.CheckReturnValue",
"justification": "Annotate mutating methods with @CheckReturnValue"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.datastax.oss.driver.internal.core.util.Sizes;
import com.datastax.oss.driver.shaded.guava.common.collect.ImmutableList;
import com.datastax.oss.protocol.internal.PrimitiveSizes;
import edu.umd.cs.findbugs.annotations.CheckReturnValue;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
import java.util.ArrayList;
Expand Down Expand Up @@ -164,6 +165,7 @@ static BatchStatementBuilder builder(@NonNull BatchStatement template) {
* method. However custom implementations may choose to be mutable and return the same instance.
*/
@NonNull
@CheckReturnValue
BatchStatement setBatchType(@NonNull BatchType newBatchType);

/**
Expand All @@ -180,13 +182,15 @@ static BatchStatementBuilder builder(@NonNull BatchStatement template) {
* @see Request#getKeyspace()
*/
@NonNull
@CheckReturnValue
BatchStatement setKeyspace(@Nullable CqlIdentifier newKeyspace);

/**
* Shortcut for {@link #setKeyspace(CqlIdentifier)
* setKeyspace(CqlIdentifier.fromCql(newKeyspaceName))}.
*/
@NonNull
@CheckReturnValue
default BatchStatement setKeyspace(@NonNull String newKeyspaceName) {
return setKeyspace(CqlIdentifier.fromCql(newKeyspaceName));
}
Expand All @@ -201,6 +205,7 @@ default BatchStatement setKeyspace(@NonNull String newKeyspaceName) {
* method. However custom implementations may choose to be mutable and return the same instance.
*/
@NonNull
@CheckReturnValue
BatchStatement add(@NonNull BatchableStatement<?> statement);

/**
Expand All @@ -213,10 +218,12 @@ default BatchStatement setKeyspace(@NonNull String newKeyspaceName) {
* method. However custom implementations may choose to be mutable and return the same instance.
*/
@NonNull
@CheckReturnValue
BatchStatement addAll(@NonNull Iterable<? extends BatchableStatement<?>> statements);

/** @see #addAll(Iterable) */
@NonNull
@CheckReturnValue
default BatchStatement addAll(@NonNull BatchableStatement<?>... statements) {
return addAll(Arrays.asList(statements));
}
Expand All @@ -231,6 +238,7 @@ default BatchStatement addAll(@NonNull BatchableStatement<?>... statements) {
* method. However custom implementations may choose to be mutable and return the same instance.
*/
@NonNull
@CheckReturnValue
BatchStatement clear();

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.datastax.oss.protocol.internal.PrimitiveSizes;
import com.datastax.oss.protocol.internal.util.collection.NullAllowingImmutableList;
import com.datastax.oss.protocol.internal.util.collection.NullAllowingImmutableMap;
import edu.umd.cs.findbugs.annotations.CheckReturnValue;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
import java.util.List;
Expand Down Expand Up @@ -197,6 +198,7 @@ static SimpleStatementBuilder builder(@NonNull SimpleStatement template) {
* @see #setNamedValuesWithIds(Map)
*/
@NonNull
@CheckReturnValue
SimpleStatement setQuery(@NonNull String newQuery);

/**
Expand All @@ -209,13 +211,15 @@ static SimpleStatementBuilder builder(@NonNull SimpleStatement template) {
* @see Request#getKeyspace()
*/
@NonNull
@CheckReturnValue
SimpleStatement setKeyspace(@Nullable CqlIdentifier newKeyspace);

/**
* Shortcut for {@link #setKeyspace(CqlIdentifier)
* setKeyspace(CqlIdentifier.fromCql(newKeyspaceName))}.
*/
@NonNull
@CheckReturnValue
default SimpleStatement setKeyspace(@NonNull String newKeyspaceName) {
return setKeyspace(CqlIdentifier.fromCql(newKeyspaceName));
}
Expand All @@ -236,6 +240,7 @@ default SimpleStatement setKeyspace(@NonNull String newKeyspaceName) {
* @see #setQuery(String)
*/
@NonNull
@CheckReturnValue
SimpleStatement setPositionalValues(@NonNull List<Object> newPositionalValues);

@NonNull
Expand All @@ -256,13 +261,15 @@ default SimpleStatement setKeyspace(@NonNull String newKeyspaceName) {
* @see #setQuery(String)
*/
@NonNull
@CheckReturnValue
SimpleStatement setNamedValuesWithIds(@NonNull Map<CqlIdentifier, Object> newNamedValues);

/**
* Shortcut for {@link #setNamedValuesWithIds(Map)} with raw strings as value names. The keys are
* converted on the fly with {@link CqlIdentifier#fromCql(String)}.
*/
@NonNull
@CheckReturnValue
default SimpleStatement setNamedValues(@NonNull Map<String, Object> newNamedValues) {
return setNamedValuesWithIds(DefaultSimpleStatement.wrapKeys(newNamedValues));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ default int getNowInSeconds() {
* @see #NO_NOW_IN_SECONDS
*/
@NonNull
@CheckReturnValue
@SuppressWarnings("unchecked")
default SelfT setNowInSeconds(int nowInSeconds) {
return (SelfT) this;
Expand Down