diff --git a/api-common-java/pom.xml b/api-common-java/pom.xml index 2a1c4b8623..f51196fca1 100644 --- a/api-common-java/pom.xml +++ b/api-common-java/pom.xml @@ -51,9 +51,9 @@ ${auto-value.version} - com.google.code.findbugs - jsr305 - 3.0.2 + org.jspecify + jspecify + 1.0.0 javax.annotation diff --git a/api-common-java/src/main/java/com/google/api/core/AbstractApiFuture.java b/api-common-java/src/main/java/com/google/api/core/AbstractApiFuture.java index 04d17bb016..824a218df0 100644 --- a/api-common-java/src/main/java/com/google/api/core/AbstractApiFuture.java +++ b/api-common-java/src/main/java/com/google/api/core/AbstractApiFuture.java @@ -35,7 +35,7 @@ import java.util.concurrent.Executor; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; /** Abstract implementation of ApiFuture that mirrors {@code AbstractFuture} in Guava. */ public abstract class AbstractApiFuture implements ApiFuture { diff --git a/api-common-java/src/main/java/com/google/api/core/ApiFutures.java b/api-common-java/src/main/java/com/google/api/core/ApiFutures.java index 780c50a783..72452a935d 100644 --- a/api-common-java/src/main/java/com/google/api/core/ApiFutures.java +++ b/api-common-java/src/main/java/com/google/api/core/ApiFutures.java @@ -39,7 +39,7 @@ import com.google.common.util.concurrent.ListenableFuture; import java.util.List; import java.util.concurrent.Executor; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; /** Static utility methods for the {@link ApiFuture} interface. */ public final class ApiFutures { diff --git a/api-common-java/src/main/java/com/google/api/pathtemplate/PathTemplate.java b/api-common-java/src/main/java/com/google/api/pathtemplate/PathTemplate.java index cc9f4c110e..9897fefdcf 100644 --- a/api-common-java/src/main/java/com/google/api/pathtemplate/PathTemplate.java +++ b/api-common-java/src/main/java/com/google/api/pathtemplate/PathTemplate.java @@ -47,7 +47,7 @@ import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; /** * Represents a path template. diff --git a/api-common-java/src/main/java/com/google/api/pathtemplate/TemplatedResourceName.java b/api-common-java/src/main/java/com/google/api/pathtemplate/TemplatedResourceName.java index f448f9677c..ad644f4dbf 100644 --- a/api-common-java/src/main/java/com/google/api/pathtemplate/TemplatedResourceName.java +++ b/api-common-java/src/main/java/com/google/api/pathtemplate/TemplatedResourceName.java @@ -37,7 +37,7 @@ import java.util.Map; import java.util.Objects; import java.util.Set; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; /** * Class for representing and working with resource names. diff --git a/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/AnnotationNode.java b/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/AnnotationNode.java index 7cb0f5ec37..a5a3c33d6e 100644 --- a/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/AnnotationNode.java +++ b/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/AnnotationNode.java @@ -19,7 +19,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; @AutoValue public abstract class AnnotationNode implements AstNode { diff --git a/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/ClassDefinition.java b/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/ClassDefinition.java index 4e1211ba3a..6931339163 100644 --- a/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/ClassDefinition.java +++ b/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/ClassDefinition.java @@ -21,7 +21,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; @AutoValue public abstract class ClassDefinition implements AstNode { diff --git a/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/ConcreteReference.java b/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/ConcreteReference.java index 48288ab817..a47855c541 100644 --- a/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/ConcreteReference.java +++ b/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/ConcreteReference.java @@ -19,7 +19,7 @@ import java.util.Arrays; import java.util.List; import java.util.Objects; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; @AutoValue public abstract class ConcreteReference implements Reference { diff --git a/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/MethodDefinition.java b/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/MethodDefinition.java index 4b65d14789..e1ede831f5 100644 --- a/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/MethodDefinition.java +++ b/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/MethodDefinition.java @@ -23,7 +23,7 @@ import java.util.List; import java.util.Set; import java.util.stream.Collectors; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; @AutoValue public abstract class MethodDefinition implements AstNode { diff --git a/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/MethodInvocationExpr.java b/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/MethodInvocationExpr.java index 2a0c2a45c4..bd61901c14 100644 --- a/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/MethodInvocationExpr.java +++ b/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/MethodInvocationExpr.java @@ -19,7 +19,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; @AutoValue public abstract class MethodInvocationExpr implements Expr { diff --git a/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/Reference.java b/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/Reference.java index 4dce11783f..792fbe539c 100644 --- a/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/Reference.java +++ b/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/Reference.java @@ -16,7 +16,7 @@ import com.google.common.collect.ImmutableList; import java.util.List; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; public interface Reference extends AstNode { @Override diff --git a/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/ThrowExpr.java b/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/ThrowExpr.java index 5e4808d28a..dcee4fa3f8 100644 --- a/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/ThrowExpr.java +++ b/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/ThrowExpr.java @@ -16,7 +16,7 @@ import com.google.auto.value.AutoValue; import com.google.common.base.Preconditions; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; @AutoValue public abstract class ThrowExpr implements Expr { diff --git a/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/TryCatchStatement.java b/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/TryCatchStatement.java index 1280635e38..61efac914a 100644 --- a/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/TryCatchStatement.java +++ b/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/TryCatchStatement.java @@ -20,8 +20,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; @AutoValue public abstract class TryCatchStatement implements Statement { @@ -60,7 +60,7 @@ public abstract static class Builder { public abstract Builder setIsSampleCode(boolean isSampleCode); - public Builder addCatch(@Nonnull VariableExpr variableExpr, List body) { + public Builder addCatch(@NonNull VariableExpr variableExpr, List body) { List catchVarExprs = new ArrayList<>(catchVariableExprs()); catchVarExprs.add(variableExpr); setCatchVariableExprs(catchVarExprs); diff --git a/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/TypeNode.java b/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/TypeNode.java index b217feb057..fc68684ece 100644 --- a/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/TypeNode.java +++ b/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/TypeNode.java @@ -21,7 +21,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; @AutoValue public abstract class TypeNode implements AstNode, Comparable { diff --git a/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/VaporReference.java b/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/VaporReference.java index 8c0cc858fa..63abc0d8ec 100644 --- a/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/VaporReference.java +++ b/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/VaporReference.java @@ -20,7 +20,7 @@ import java.util.Collections; import java.util.List; import java.util.Objects; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; @AutoValue public abstract class VaporReference implements Reference { diff --git a/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/VariableExpr.java b/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/VariableExpr.java index f882c97e8d..d3ef76c592 100644 --- a/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/VariableExpr.java +++ b/gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/VariableExpr.java @@ -22,7 +22,7 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.stream.Collectors; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; @AutoValue public abstract class VariableExpr implements Expr { diff --git a/gapic-generator-java/src/main/java/com/google/api/generator/engine/writer/ImportWriterVisitor.java b/gapic-generator-java/src/main/java/com/google/api/generator/engine/writer/ImportWriterVisitor.java index e19e168c3e..3552a97e4f 100644 --- a/gapic-generator-java/src/main/java/com/google/api/generator/engine/writer/ImportWriterVisitor.java +++ b/gapic-generator-java/src/main/java/com/google/api/generator/engine/writer/ImportWriterVisitor.java @@ -69,8 +69,8 @@ import java.util.Set; import java.util.TreeSet; import java.util.stream.Collectors; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; public class ImportWriterVisitor implements AstNodeVisitor { private static final String DOT = "."; @@ -91,12 +91,12 @@ public void clear() { importShortNames.clear(); } - public void initialize(@Nonnull String currentPackage) { + public void initialize(@NonNull String currentPackage) { this.currentPackage = currentPackage; currentClassName = null; } - public void initialize(@Nonnull String currentPackage, @Nonnull String currentClassName) { + public void initialize(@NonNull String currentPackage, @NonNull String currentClassName) { this.currentPackage = currentPackage; this.currentClassName = currentClassName; } diff --git a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceStubSettingsClassComposer.java b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceStubSettingsClassComposer.java index ae23a0aedd..9d1ac552c9 100644 --- a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceStubSettingsClassComposer.java +++ b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceStubSettingsClassComposer.java @@ -119,7 +119,7 @@ import java.util.function.Function; import java.util.stream.Collectors; import javax.annotation.Generated; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import org.threeten.bp.Duration; public abstract class AbstractServiceStubSettingsClassComposer implements ClassComposer { diff --git a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/common/AbstractTransportServiceStubClassComposer.java b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/common/AbstractTransportServiceStubClassComposer.java index 7ea90a0b45..4496c142b8 100644 --- a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/common/AbstractTransportServiceStubClassComposer.java +++ b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/common/AbstractTransportServiceStubClassComposer.java @@ -95,7 +95,7 @@ import java.util.function.Predicate; import java.util.stream.Collectors; import javax.annotation.Generated; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; public abstract class AbstractTransportServiceStubClassComposer implements ClassComposer { private static final Statement EMPTY_LINE_STATEMENT = EmptyLineStatement.create(); diff --git a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/common/TransportContext.java b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/common/TransportContext.java index ab98a86b18..421189c6d2 100644 --- a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/common/TransportContext.java +++ b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/common/TransportContext.java @@ -20,7 +20,7 @@ import com.google.api.generator.gapic.model.Transport; import com.google.auto.value.AutoValue; import java.util.List; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; @AutoValue public abstract class TransportContext { diff --git a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/Field.java b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/Field.java index 39213909de..b69186f317 100644 --- a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/Field.java +++ b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/Field.java @@ -19,7 +19,7 @@ import com.google.auto.value.AutoValue; import java.util.Objects; import java.util.Optional; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; @AutoValue public abstract class Field { diff --git a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/GapicBatchingSettings.java b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/GapicBatchingSettings.java index 2f7d4de00d..faa770be50 100644 --- a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/GapicBatchingSettings.java +++ b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/GapicBatchingSettings.java @@ -17,7 +17,7 @@ import com.google.auto.value.AutoValue; import com.google.common.collect.ImmutableList; import java.util.List; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; @AutoValue public abstract class GapicBatchingSettings { diff --git a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/GapicContext.java b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/GapicContext.java index 780890c664..1747bec25e 100644 --- a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/GapicContext.java +++ b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/GapicContext.java @@ -25,7 +25,7 @@ import java.util.Set; import java.util.TreeMap; import java.util.stream.Collectors; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; @AutoValue public abstract class GapicContext { @@ -67,8 +67,7 @@ public GapicMetadata gapicMetadata() { @Nullable public abstract GapicServiceConfig serviceConfig(); - @Nullable - public abstract com.google.api.Service serviceYamlProto(); + public abstract com.google.api.@Nullable Service serviceYamlProto(); public boolean containsServices() { return !services().isEmpty(); diff --git a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/HttpBindings.java b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/HttpBindings.java index 696683cefe..c36c8a63c9 100644 --- a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/HttpBindings.java +++ b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/HttpBindings.java @@ -22,7 +22,7 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; @AutoValue public abstract class HttpBindings { diff --git a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/LongrunningOperation.java b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/LongrunningOperation.java index e23e8a6ee3..8c9d05c78e 100644 --- a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/LongrunningOperation.java +++ b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/LongrunningOperation.java @@ -16,7 +16,7 @@ import com.google.api.generator.engine.ast.TypeNode; import com.google.auto.value.AutoValue; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; @AutoValue public abstract class LongrunningOperation { diff --git a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/Message.java b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/Message.java index 2866e84624..b65443c99f 100644 --- a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/Message.java +++ b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/Message.java @@ -31,7 +31,7 @@ import java.util.Map; import java.util.stream.Collectors; import java.util.stream.IntStream; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; @AutoValue public abstract class Message { diff --git a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/Method.java b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/Method.java index f8f815cc08..736b538d9b 100644 --- a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/Method.java +++ b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/Method.java @@ -19,7 +19,7 @@ import com.google.common.collect.ImmutableList; import java.util.ArrayList; import java.util.List; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; @AutoValue public abstract class Method { diff --git a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/ResourceName.java b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/ResourceName.java index 9a01bf6dba..48740b8c01 100644 --- a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/ResourceName.java +++ b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/ResourceName.java @@ -26,7 +26,7 @@ import com.google.common.collect.ImmutableMap; import java.util.List; import java.util.Objects; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; @AutoValue public abstract class ResourceName { diff --git a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/Service.java b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/Service.java index 656bf6bbd3..48f948a855 100644 --- a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/Service.java +++ b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/Service.java @@ -21,7 +21,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import java.util.List; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; @AutoValue public abstract class Service { diff --git a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/SourceCodeInfoLocation.java b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/SourceCodeInfoLocation.java index f39cb39530..da7cac2f59 100644 --- a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/SourceCodeInfoLocation.java +++ b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/SourceCodeInfoLocation.java @@ -15,20 +15,20 @@ package com.google.api.generator.gapic.model; import com.google.protobuf.DescriptorProtos.SourceCodeInfo.Location; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; /** * A light wrapper around SourceCodeInfo.Location to provide cleaner protobuf comments. Please see * additional documentation on descriptor.proto. */ public class SourceCodeInfoLocation { - @Nonnull private final Location location; + @NonNull private final Location location; private SourceCodeInfoLocation(Location location) { this.location = location; } - public static SourceCodeInfoLocation create(@Nonnull Location location) { + public static SourceCodeInfoLocation create(@NonNull Location location) { return new SourceCodeInfoLocation(location); } diff --git a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/protoparser/ResourceReferenceParser.java b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/protoparser/ResourceReferenceParser.java index 06ccf2ec27..3a583b3b8c 100644 --- a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/protoparser/ResourceReferenceParser.java +++ b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/protoparser/ResourceReferenceParser.java @@ -29,7 +29,7 @@ import java.util.Map; import java.util.Optional; import java.util.Set; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; public class ResourceReferenceParser { private static final String EMPTY_STRING = ""; diff --git a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/protoparser/SourceCodeInfoParser.java b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/protoparser/SourceCodeInfoParser.java index 28ae95c926..3dcd19c45f 100644 --- a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/protoparser/SourceCodeInfoParser.java +++ b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/protoparser/SourceCodeInfoParser.java @@ -35,7 +35,7 @@ import com.google.protobuf.Descriptors.OneofDescriptor; import com.google.protobuf.Descriptors.ServiceDescriptor; import java.util.Map; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; /** * A helper class which provides protocol buffer source info for descriptors. diff --git a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/protoparser/TypeParser.java b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/protoparser/TypeParser.java index 49b17d25db..ea33250203 100644 --- a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/protoparser/TypeParser.java +++ b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/protoparser/TypeParser.java @@ -34,7 +34,7 @@ import java.util.Arrays; import java.util.List; import java.util.Map; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; public class TypeParser { private static Reference REFERENCE_BYTE_STRING = ConcreteReference.withClazz(ByteString.class); @@ -62,7 +62,7 @@ public class TypeParser { .put(JavaType.BYTE_STRING, REFERENCE_BYTE_STRING) .build(); - public static TypeNode parseType(@Nonnull FieldDescriptor field) { + public static TypeNode parseType(@NonNull FieldDescriptor field) { if (field.isMapField()) { return createMapType(field); } @@ -83,11 +83,11 @@ public static TypeNode parseType(@Nonnull FieldDescriptor field) { return TypeNode.withReference(parseFieldReference(field)); } - public static TypeNode parseType(@Nonnull Descriptor messageDescriptor) { + public static TypeNode parseType(@NonNull Descriptor messageDescriptor) { return TypeNode.withReference(parseMessageReference(messageDescriptor)); } - public static TypeNode parseType(@Nonnull EnumDescriptor enumDescriptor) { + public static TypeNode parseType(@NonNull EnumDescriptor enumDescriptor) { return TypeNode.withReference(parseEnumReference(enumDescriptor)); } @@ -119,7 +119,7 @@ static Reference parseFieldReference(FieldDescriptor field) { } @VisibleForTesting - static Reference parseMessageReference(@Nonnull Descriptor messageDescriptor) { + static Reference parseMessageReference(@NonNull Descriptor messageDescriptor) { List outerNestedTypeNames = new ArrayList<>(); FileOptions fileOptions = messageDescriptor.getFile().getOptions(); String javaOuterClassname = @@ -179,7 +179,7 @@ static Reference parseMessageReference(@Nonnull Descriptor messageDescriptor) { } @VisibleForTesting - static Reference parseEnumReference(@Nonnull EnumDescriptor enumDescriptor) { + static Reference parseEnumReference(@NonNull EnumDescriptor enumDescriptor) { // This is similar to parseMessageReference, but we make it a separate method because // EnumDescriptor and Descriptor are sibling types. FileOptions fileOptions = enumDescriptor.getFile().getOptions(); diff --git a/gax-java/dependencies.properties b/gax-java/dependencies.properties index 6943ad61e7..3b0293983b 100644 --- a/gax-java/dependencies.properties +++ b/gax-java/dependencies.properties @@ -62,7 +62,7 @@ maven.com_google_guava_guava=com.google.guava:guava:32.1.3-jre maven.com_google_guava_failureaccess=com.google.guava:failureaccess:1.0.2 maven.org_apache_commons_commons_lang3=org.apache.commons:commons-lang3:3.17.0 maven.com_google_android_annotations=com.google.android:annotations:4.1.1.4 -maven.com_google_code_findbugs_jsr305=com.google.code.findbugs:jsr305:3.0.2 +maven.org_jspecify_jspecify=org.jspecify:jspecify:1.0.0 maven.com_google_errorprone_error_prone_annotations=com.google.errorprone:error_prone_annotations:2.33.0 maven.com_google_j2objc_j2objc_annotations=com.google.j2objc:j2objc-annotations:2.8 maven.com_google_auto_value_auto_value=com.google.auto.value:auto-value:1.11.0 diff --git a/gax-java/gax-grpc/BUILD.bazel b/gax-java/gax-grpc/BUILD.bazel index be224ff3f8..8fbc654a8f 100644 --- a/gax-java/gax-grpc/BUILD.bazel +++ b/gax-java/gax-grpc/BUILD.bazel @@ -14,7 +14,7 @@ _COMPILE_DEPS = [ "@io_grpc_grpc_java//protobuf:protobuf", "@com_google_protobuf//:protobuf_java", "@com_google_guava_guava//jar", - "@com_google_code_findbugs_jsr305//jar", + "@org_jspecify_jspecify//jar", "@com_google_code_gson_gson//jar", "@org_threeten_threetenbp//jar", "@com_google_auth_google_auth_library_oauth2_http//jar", diff --git a/gax-java/gax-grpc/pom.xml b/gax-java/gax-grpc/pom.xml index 3caaeec2b2..0860b25876 100644 --- a/gax-java/gax-grpc/pom.xml +++ b/gax-java/gax-grpc/pom.xml @@ -78,9 +78,9 @@ runtime - com.google.code.findbugs - jsr305 - provided + org.jspecify + jspecify + 1.0.0 org.graalvm.sdk diff --git a/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/ChannelPool.java b/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/ChannelPool.java index 12f226d2b6..e2f1f8a3c6 100644 --- a/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/ChannelPool.java +++ b/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/ChannelPool.java @@ -54,7 +54,7 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; /** * A {@link ManagedChannel} that will send requests round-robin via a set of channels. @@ -562,7 +562,8 @@ public void onClose(Status status, Metadata trailers) { if (!wasClosed.compareAndSet(false, true)) { LOG.log( Level.WARNING, - "Call is being closed more than once. Please make sure that onClose() is not being manually called."); + "Call is being closed more than once. Please make sure that onClose() is not" + + " being manually called."); return; } try { @@ -573,7 +574,8 @@ public void onClose(Status status, Metadata trailers) { } else { LOG.log( Level.WARNING, - "Entry was released before the call is closed. This may be due to an exception on start of the call."); + "Entry was released before the call is closed. This may be due to an" + + " exception on start of the call."); } } } @@ -586,7 +588,8 @@ public void onClose(Status status, Metadata trailers) { } else { LOG.log( Level.WARNING, - "The entry is already released. This indicates that onClose() has already been called previously"); + "The entry is already released. This indicates that onClose() has already been called" + + " previously"); } throw e; } diff --git a/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/GrpcCallContext.java b/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/GrpcCallContext.java index 137060595d..ee898af17e 100644 --- a/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/GrpcCallContext.java +++ b/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/GrpcCallContext.java @@ -64,8 +64,8 @@ import java.util.Map; import java.util.Objects; import java.util.Set; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; /** * GrpcCallContext encapsulates context data used to make a grpc call. @@ -87,9 +87,9 @@ public final class GrpcCallContext implements ApiCallContext { private final Channel channel; @Nullable private final Credentials credentials; private final CallOptions callOptions; - @Nullable private final java.time.Duration timeout; - @Nullable private final java.time.Duration streamWaitTimeout; - @Nullable private final java.time.Duration streamIdleTimeout; + private final java.time.@Nullable Duration timeout; + private final java.time.@Nullable Duration streamWaitTimeout; + private final java.time.@Nullable Duration streamIdleTimeout; @Nullable private final Integer channelAffinity; @Nullable private final RetrySettings retrySettings; @Nullable private final ImmutableSet retryableCodes; @@ -135,9 +135,9 @@ private GrpcCallContext( Channel channel, @Nullable Credentials credentials, CallOptions callOptions, - @Nullable java.time.Duration timeout, - @Nullable java.time.Duration streamWaitTimeout, - @Nullable java.time.Duration streamIdleTimeout, + java.time.@Nullable Duration timeout, + java.time.@Nullable Duration streamWaitTimeout, + java.time.@Nullable Duration streamIdleTimeout, @Nullable Integer channelAffinity, ImmutableMap> extraHeaders, ApiCallContextOptions options, @@ -234,12 +234,12 @@ public GrpcCallContext withEndpointContext(EndpointContext endpointContext) { /** This method is obsolete. Use {@link #withTimeoutDuration(java.time.Duration)} instead. */ @Override @ObsoleteApi("Use withTimeoutDuration(java.time.Duration) instead") - public GrpcCallContext withTimeout(@Nullable org.threeten.bp.Duration timeout) { + public GrpcCallContext withTimeout(org.threeten.bp.@Nullable Duration timeout) { return withTimeoutDuration(toJavaTimeDuration(timeout)); } @Override - public GrpcCallContext withTimeoutDuration(@Nullable java.time.Duration timeout) { + public GrpcCallContext withTimeoutDuration(java.time.@Nullable Duration timeout) { // Default RetrySettings use 0 for RPC timeout. Treat that as disabled timeouts. if (timeout != null && (timeout.isZero() || timeout.isNegative())) { timeout = null; @@ -266,16 +266,14 @@ public GrpcCallContext withTimeoutDuration(@Nullable java.time.Duration timeout) } /** This method is obsolete. Use {@link #getTimeoutDuration()} instead. */ - @Nullable @Override @ObsoleteApi("Use getTimeoutDuration() instead") - public org.threeten.bp.Duration getTimeout() { + public org.threeten.bp.@Nullable Duration getTimeout() { return toThreetenDuration(getTimeoutDuration()); } - @Nullable @Override - public java.time.Duration getTimeoutDuration() { + public java.time.@Nullable Duration getTimeoutDuration() { return timeout; } @@ -286,13 +284,13 @@ public java.time.Duration getTimeoutDuration() { @Override @ObsoleteApi("Use withStreamWaitTimeoutDuration(java.time.Duration) instead") public GrpcCallContext withStreamWaitTimeout( - @Nullable org.threeten.bp.Duration streamWaitTimeout) { + org.threeten.bp.@Nullable Duration streamWaitTimeout) { return withStreamWaitTimeoutDuration(toJavaTimeDuration(streamWaitTimeout)); } @Override public GrpcCallContext withStreamWaitTimeoutDuration( - @Nullable java.time.Duration streamWaitTimeout) { + java.time.@Nullable Duration streamWaitTimeout) { if (streamWaitTimeout != null) { Preconditions.checkArgument( streamWaitTimeout.compareTo(java.time.Duration.ZERO) >= 0, "Invalid timeout: < 0 s"); @@ -320,13 +318,13 @@ public GrpcCallContext withStreamWaitTimeoutDuration( @Override @ObsoleteApi("Use withStreamIdleTimeoutDuration(java.time.Duration) instead") public GrpcCallContext withStreamIdleTimeout( - @Nullable org.threeten.bp.Duration streamIdleTimeout) { + org.threeten.bp.@Nullable Duration streamIdleTimeout) { return withStreamIdleTimeoutDuration(toJavaTimeDuration(streamIdleTimeout)); } @Override public GrpcCallContext withStreamIdleTimeoutDuration( - @Nullable java.time.Duration streamIdleTimeout) { + java.time.@Nullable Duration streamIdleTimeout) { if (streamIdleTimeout != null) { Preconditions.checkArgument( streamIdleTimeout.compareTo(java.time.Duration.ZERO) >= 0, "Invalid timeout: < 0 s"); @@ -540,9 +538,8 @@ public CallOptions getCallOptions() { /** This method is obsolete. Use {@link #getStreamWaitTimeoutDuration()} instead. */ @Override - @Nullable @ObsoleteApi("Use getStreamWaitTimeoutDuration() instead") - public org.threeten.bp.Duration getStreamWaitTimeout() { + public org.threeten.bp.@Nullable Duration getStreamWaitTimeout() { return toThreetenDuration(getStreamWaitTimeoutDuration()); } @@ -552,26 +549,24 @@ public org.threeten.bp.Duration getStreamWaitTimeout() { * @see ApiCallContext#withStreamWaitTimeoutDuration(java.time.Duration) */ @Override - @Nullable - public java.time.Duration getStreamWaitTimeoutDuration() { + public java.time.@Nullable Duration getStreamWaitTimeoutDuration() { return streamWaitTimeout; } /** This method is obsolete. Use {@link #getStreamIdleTimeoutDuration()} instead. */ @Override - @Nullable @ObsoleteApi("Use getStreamIdleTimeoutDuration() instead") - public org.threeten.bp.Duration getStreamIdleTimeout() { + public org.threeten.bp.@Nullable Duration getStreamIdleTimeout() { return toThreetenDuration(getStreamIdleTimeoutDuration()); } + /** * The stream idle timeout set for this context. * * @see ApiCallContext#withStreamIdleTimeoutDuration(java.time.Duration) */ @Override - @Nullable - public java.time.Duration getStreamIdleTimeoutDuration() { + public java.time.@Nullable Duration getStreamIdleTimeoutDuration() { return streamIdleTimeout; } @@ -631,7 +626,7 @@ public GrpcCallContext withRequestParamsDynamicHeaderOption(String requestParams /** {@inheritDoc} */ @Override - @Nonnull + @NonNull public ApiTracer getTracer() { ApiTracer tracer = callOptions.getOption(TRACER_KEY); if (tracer == null) { @@ -642,7 +637,7 @@ public ApiTracer getTracer() { /** {@inheritDoc} */ @Override - public GrpcCallContext withTracer(@Nonnull ApiTracer tracer) { + public GrpcCallContext withTracer(@NonNull ApiTracer tracer) { Preconditions.checkNotNull(tracer); return withCallOptions(callOptions.withOption(TRACER_KEY, tracer)); } diff --git a/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/GrpcCallableFactory.java b/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/GrpcCallableFactory.java index 974feb0c43..3d703ea701 100644 --- a/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/GrpcCallableFactory.java +++ b/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/GrpcCallableFactory.java @@ -61,7 +61,7 @@ import io.grpc.MethodDescriptor; import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; /** Class with utility methods to create grpc-based direct callables. */ public class GrpcCallableFactory { @@ -329,7 +329,7 @@ ClientStreamingCallable createClientStreamingCallable( } @InternalApi("Visible for testing") - static SpanName getSpanName(@Nonnull MethodDescriptor methodDescriptor) { + static SpanName getSpanName(@NonNull MethodDescriptor methodDescriptor) { Matcher matcher = FULL_METHOD_NAME_REGEX.matcher(methodDescriptor.getFullMethodName()); Preconditions.checkArgument(matcher.matches(), "Invalid fullMethodName"); diff --git a/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProvider.java b/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProvider.java index ae4d7f9e51..7932fb9b98 100644 --- a/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProvider.java +++ b/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProvider.java @@ -72,8 +72,8 @@ import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.Nullable; import javax.net.ssl.KeyManagerFactory; +import org.jspecify.annotations.Nullable; /** * InstantiatingGrpcChannelProvider is a TransportChannelProvider which constructs a gRPC @@ -115,8 +115,8 @@ public final class InstantiatingGrpcChannelProvider implements TransportChannelP @Nullable private final GrpcInterceptorProvider interceptorProvider; @Nullable private final Integer maxInboundMessageSize; @Nullable private final Integer maxInboundMetadataSize; - @Nullable private final java.time.Duration keepAliveTime; - @Nullable private final java.time.Duration keepAliveTimeout; + private final java.time.@Nullable Duration keepAliveTime; + private final java.time.@Nullable Duration keepAliveTimeout; @Nullable private final Boolean keepAliveWithoutCalls; private final ChannelPoolSettings channelPoolSettings; @Nullable private final Credentials credentials; @@ -319,8 +319,9 @@ private void logDirectPathMisconfig() { Level.WARNING, "Env var " + DIRECT_PATH_ENV_ENABLE_XDS - + " was found and set to TRUE, but DirectPath was not enabled for this client. If this is intended for " - + "this client, please note that this is a misconfiguration and set the attemptDirectPath option as well."); + + " was found and set to TRUE, but DirectPath was not enabled for this client. If" + + " this is intended for this client, please note that this is a misconfiguration" + + " and set the attemptDirectPath option as well."); } // Case 2: Direct Path xDS was enabled via Builder. Direct Path Traffic Director must be set // (enabled with `setAttemptDirectPath(true)`) along with xDS. @@ -328,7 +329,9 @@ private void logDirectPathMisconfig() { else if (isDirectPathXdsEnabledViaBuilderOption()) { LOG.log( Level.WARNING, - "DirectPath is misconfigured. The DirectPath XDS option was set, but the attemptDirectPath option was not. Please set both the attemptDirectPath and attemptDirectPathXds options."); + "DirectPath is misconfigured. The DirectPath XDS option was set, but the" + + " attemptDirectPath option was not. Please set both the attemptDirectPath and" + + " attemptDirectPathXds options."); } } else { // Case 3: credential is not correctly set @@ -609,8 +612,8 @@ public static final class Builder { @Nullable private GrpcInterceptorProvider interceptorProvider; @Nullable private Integer maxInboundMessageSize; @Nullable private Integer maxInboundMetadataSize; - @Nullable private java.time.Duration keepAliveTime; - @Nullable private java.time.Duration keepAliveTimeout; + private java.time.@Nullable Duration keepAliveTime; + private java.time.@Nullable Duration keepAliveTimeout; @Nullable private Boolean keepAliveWithoutCalls; @Nullable private ApiFunction channelConfigurator; @Nullable private Credentials credentials; diff --git a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcDirectStreamControllerTest.java b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcDirectStreamControllerTest.java index 2359dc5d28..6c8d6e5a04 100644 --- a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcDirectStreamControllerTest.java +++ b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcDirectStreamControllerTest.java @@ -52,8 +52,8 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Timeout; @@ -68,13 +68,13 @@ void testRetryNoRaceCondition() throws Exception { ManagedChannelBuilder.forAddress("localhost", 1234).usePlaintext().build(); StreamResumptionStrategy resumptionStrategy = new StreamResumptionStrategy() { - @Nonnull + @NonNull @Override public StreamResumptionStrategy createNew() { return this; } - @Nonnull + @NonNull @Override public Money processResponse(Money response) { return response; diff --git a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProviderTest.java b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProviderTest.java index a58f9b8173..820a784936 100644 --- a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProviderTest.java +++ b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProviderTest.java @@ -73,7 +73,7 @@ import java.util.logging.Handler; import java.util.logging.LogRecord; import java.util.stream.Collectors; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; @@ -626,7 +626,9 @@ private void createAndCloseTransportChannel(InstantiatingGrpcChannelProvider pro createAndCloseTransportChannel(provider); assertThat(logHandler.getAllMessages()) .contains( - "DirectPath is misconfigured. The DirectPath XDS option was set, but the attemptDirectPath option was not. Please set both the attemptDirectPath and attemptDirectPathXds options."); + "DirectPath is misconfigured. The DirectPath XDS option was set, but the" + + " attemptDirectPath option was not. Please set both the attemptDirectPath and" + + " attemptDirectPathXds options."); InstantiatingGrpcChannelProvider.LOG.removeHandler(logHandler); } @@ -641,8 +643,10 @@ void testLogDirectPathMisconfig_AttemptDirectPathNotSetAndAttemptDirectPathXdsSe createAndCloseTransportChannel(provider); assertThat(logHandler.getAllMessages()) .contains( - "Env var GOOGLE_CLOUD_ENABLE_DIRECT_PATH_XDS was found and set to TRUE, but DirectPath was not enabled for this client. If this is intended for " - + "this client, please note that this is a misconfiguration and set the attemptDirectPath option as well."); + "Env var GOOGLE_CLOUD_ENABLE_DIRECT_PATH_XDS was found and set to TRUE, but DirectPath" + + " was not enabled for this client. If this is intended for this client, please" + + " note that this is a misconfiguration and set the attemptDirectPath option as" + + " well."); InstantiatingGrpcChannelProvider.LOG.removeHandler(logHandler); } diff --git a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/MockClientCall.java b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/MockClientCall.java index a1720293f0..378dd29561 100644 --- a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/MockClientCall.java +++ b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/MockClientCall.java @@ -32,7 +32,7 @@ import io.grpc.ClientCall; import io.grpc.Metadata; import io.grpc.Status; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; public class MockClientCall extends ClientCall { diff --git a/gax-java/gax-httpjson/BUILD.bazel b/gax-java/gax-httpjson/BUILD.bazel index 1e134e6770..62e74324c6 100644 --- a/gax-java/gax-httpjson/BUILD.bazel +++ b/gax-java/gax-httpjson/BUILD.bazel @@ -10,7 +10,7 @@ _JAVA_COPTS = [ _COMPILE_DEPS = [ "@com_google_code_gson_gson//jar", "@com_google_guava_guava//jar", - "@com_google_code_findbugs_jsr305//jar", + "@org_jspecify_jspecify//jar", "@com_google_errorprone_error_prone_annotations//jar", "@org_threeten_threetenbp//jar", "@com_google_http_client_google_http_client//jar", diff --git a/gax-java/gax-httpjson/pom.xml b/gax-java/gax-httpjson/pom.xml index f1309e7c18..643d4fef61 100644 --- a/gax-java/gax-httpjson/pom.xml +++ b/gax-java/gax-httpjson/pom.xml @@ -69,9 +69,9 @@ protobuf-java-util - com.google.code.findbugs - jsr305 - provided + org.jspecify + jspecify + 1.0.0 com.google.auto.value diff --git a/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/ApiMethodDescriptor.java b/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/ApiMethodDescriptor.java index 69e2e0fff7..8fc7d8411e 100644 --- a/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/ApiMethodDescriptor.java +++ b/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/ApiMethodDescriptor.java @@ -30,7 +30,7 @@ package com.google.api.gax.httpjson; import com.google.auto.value.AutoValue; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; @AutoValue /* Method descriptor for messages to be transmitted over HTTP. */ diff --git a/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/ForwardingHttpJsonClientCall.java b/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/ForwardingHttpJsonClientCall.java index 09e97a61c8..6f2e108c14 100644 --- a/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/ForwardingHttpJsonClientCall.java +++ b/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/ForwardingHttpJsonClientCall.java @@ -29,7 +29,7 @@ */ package com.google.api.gax.httpjson; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; /** * A {@link HttpJsonClientCall} which forwards all of its methods to another {@link diff --git a/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonCallContext.java b/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonCallContext.java index 2b2d675a2a..5dd74b129c 100644 --- a/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonCallContext.java +++ b/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonCallContext.java @@ -55,8 +55,8 @@ import java.util.Map; import java.util.Objects; import java.util.Set; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; /** * HttpJsonCallContext encapsulates context data used to make an http-json call. @@ -71,9 +71,9 @@ public final class HttpJsonCallContext implements ApiCallContext { HttpJsonStatusCode.of(StatusCode.Code.UNAUTHENTICATED); private final HttpJsonChannel channel; private final HttpJsonCallOptions callOptions; - @Nullable private final java.time.Duration timeout; - @Nullable private final java.time.Duration streamWaitTimeout; - @Nullable private final java.time.Duration streamIdleTimeout; + private final java.time.@Nullable Duration timeout; + private final java.time.@Nullable Duration streamWaitTimeout; + private final java.time.@Nullable Duration streamIdleTimeout; private final ImmutableMap> extraHeaders; private final ApiCallContextOptions options; private final ApiTracer tracer; @@ -303,16 +303,14 @@ public HttpJsonCallContext withTimeoutDuration(java.time.Duration timeout) { } /** This method is obsolete. Use {@link #getTimeoutDuration()} instead. */ - @Nullable @Override @ObsoleteApi("Use getTimeoutDuration instead") - public org.threeten.bp.Duration getTimeout() { + public org.threeten.bp.@Nullable Duration getTimeout() { return toThreetenDuration(getTimeoutDuration()); } - @Nullable @Override - public java.time.Duration getTimeoutDuration() { + public java.time.@Nullable Duration getTimeoutDuration() { return timeout; } @@ -323,13 +321,13 @@ public java.time.Duration getTimeoutDuration() { @Override @ObsoleteApi("Use withStreamWaitTimeoutDuration(java.time.Duration) instead") public HttpJsonCallContext withStreamWaitTimeout( - @Nullable org.threeten.bp.Duration streamWaitTimeout) { + org.threeten.bp.@Nullable Duration streamWaitTimeout) { return withStreamWaitTimeoutDuration(toJavaTimeDuration(streamWaitTimeout)); } @Override public HttpJsonCallContext withStreamWaitTimeoutDuration( - @Nullable java.time.Duration streamWaitTimeout) { + java.time.@Nullable Duration streamWaitTimeout) { if (streamWaitTimeout != null) { Preconditions.checkArgument( streamWaitTimeout.compareTo(java.time.Duration.ZERO) >= 0, "Invalid timeout: < 0 s"); @@ -351,9 +349,8 @@ public HttpJsonCallContext withStreamWaitTimeoutDuration( /** This method is obsolete. Use {@link #getStreamWaitTimeoutDuration()} instead. */ @Override - @Nullable @ObsoleteApi("Use getStreamWaitTimeoutDuration() instead") - public org.threeten.bp.Duration getStreamWaitTimeout() { + public org.threeten.bp.@Nullable Duration getStreamWaitTimeout() { return toThreetenDuration(getStreamWaitTimeoutDuration()); } @@ -363,8 +360,7 @@ public org.threeten.bp.Duration getStreamWaitTimeout() { * @see ApiCallContext#withStreamWaitTimeoutDuration(java.time.Duration) */ @Override - @Nullable - public java.time.Duration getStreamWaitTimeoutDuration() { + public java.time.@Nullable Duration getStreamWaitTimeoutDuration() { return streamWaitTimeout; } @@ -375,13 +371,13 @@ public java.time.Duration getStreamWaitTimeoutDuration() { @Override @ObsoleteApi("Use withStreamIdleTimeoutDuration(java.time.Duration) instead") public HttpJsonCallContext withStreamIdleTimeout( - @Nullable org.threeten.bp.Duration streamIdleTimeout) { + org.threeten.bp.@Nullable Duration streamIdleTimeout) { return withStreamIdleTimeoutDuration(toJavaTimeDuration(streamIdleTimeout)); } @Override public HttpJsonCallContext withStreamIdleTimeoutDuration( - @Nullable java.time.Duration streamIdleTimeout) { + java.time.@Nullable Duration streamIdleTimeout) { if (streamIdleTimeout != null) { Preconditions.checkArgument( streamIdleTimeout.compareTo(java.time.Duration.ZERO) >= 0, "Invalid timeout: < 0 s"); @@ -403,9 +399,8 @@ public HttpJsonCallContext withStreamIdleTimeoutDuration( /** This method is obsolete. Use {@link #getStreamIdleTimeoutDuration()} instead. */ @Override - @Nullable @ObsoleteApi("Use getStreamIdleTimeoutDuration() instead") - public org.threeten.bp.Duration getStreamIdleTimeout() { + public org.threeten.bp.@Nullable Duration getStreamIdleTimeout() { return toThreetenDuration(getStreamIdleTimeoutDuration()); } @@ -415,8 +410,7 @@ public org.threeten.bp.Duration getStreamIdleTimeout() { * @see ApiCallContext#withStreamIdleTimeoutDuration(java.time.Duration) */ @Override - @Nullable - public java.time.Duration getStreamIdleTimeoutDuration() { + public java.time.@Nullable Duration getStreamIdleTimeoutDuration() { return streamIdleTimeout; } @@ -504,8 +498,7 @@ public HttpJsonCallOptions getCallOptions() { } @Deprecated - @Nullable - public org.threeten.bp.Instant getDeadline() { + public org.threeten.bp.@Nullable Instant getDeadline() { return getCallOptions() != null ? getCallOptions().getDeadline() : null; } @@ -594,7 +587,7 @@ public HttpJsonCallContext withDeadline(org.threeten.bp.Instant newDeadline) { return withCallOptions(builder.setDeadline(newDeadline).build()); } - @Nonnull + @NonNull @Override public ApiTracer getTracer() { if (tracer == null) { @@ -605,7 +598,7 @@ public ApiTracer getTracer() { /** {@inheritDoc} */ @Override - public HttpJsonCallContext withTracer(@Nonnull ApiTracer newTracer) { + public HttpJsonCallContext withTracer(@NonNull ApiTracer newTracer) { Preconditions.checkNotNull(newTracer); return new HttpJsonCallContext( diff --git a/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonCallOptions.java b/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonCallOptions.java index 4c2d8ae55e..7c7702b131 100644 --- a/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonCallOptions.java +++ b/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonCallOptions.java @@ -38,7 +38,7 @@ import com.google.auth.Credentials; import com.google.auto.value.AutoValue; import com.google.protobuf.TypeRegistry; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; /** Options for an http-json call, including deadline and credentials. */ @AutoValue @@ -46,24 +46,20 @@ public abstract class HttpJsonCallOptions { public static final HttpJsonCallOptions DEFAULT = newBuilder().build(); /** This method is obsolete. Use {@link #getTimeoutDuration()} instead. */ - @Nullable @ObsoleteApi("Use getTimeoutDuration() instead") - public final org.threeten.bp.Duration getTimeout() { + public final org.threeten.bp.@Nullable Duration getTimeout() { return toThreetenDuration(getTimeoutDuration()); } - @Nullable - public abstract java.time.Duration getTimeoutDuration(); + public abstract java.time.@Nullable Duration getTimeoutDuration(); /** This method is obsolete. Use {@link #getDeadlineInstant()} instead. */ - @Nullable @ObsoleteApi("Use getDeadlineInstant() instead") - public final org.threeten.bp.Instant getDeadline() { + public final org.threeten.bp.@Nullable Instant getDeadline() { return toThreetenInstant(getDeadlineInstant()); } - @Nullable - public abstract java.time.Instant getDeadlineInstant(); + public abstract java.time.@Nullable Instant getDeadlineInstant(); @Nullable public abstract Credentials getCredentials(); diff --git a/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonCallableFactory.java b/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonCallableFactory.java index 33e2ff886e..af4dcff840 100644 --- a/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonCallableFactory.java +++ b/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonCallableFactory.java @@ -48,7 +48,7 @@ import com.google.common.base.Preconditions; import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; /** Class with utility methods to create http/json-based direct callables. */ public class HttpJsonCallableFactory { @@ -228,7 +228,7 @@ ServerStreamingCallable createServerStreamingCallable( } @InternalApi("Visible for testing") - static SpanName getSpanName(@Nonnull ApiMethodDescriptor methodDescriptor) { + static SpanName getSpanName(@NonNull ApiMethodDescriptor methodDescriptor) { Matcher matcher = FULL_METHOD_NAME_REGEX.matcher(methodDescriptor.getFullMethodName()); Preconditions.checkArgument(matcher.matches(), "Invalid fullMethodName"); diff --git a/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonClientCall.java b/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonClientCall.java index e70a6eb857..16cf65486a 100644 --- a/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonClientCall.java +++ b/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonClientCall.java @@ -29,7 +29,7 @@ */ package com.google.api.gax.httpjson; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; // This class mimics the structure and behavior of the corresponding ClientCall from gRPC package as // closely as possible. diff --git a/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonClientCallImpl.java b/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonClientCallImpl.java index df9a507519..e48e7efed0 100644 --- a/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonClientCallImpl.java +++ b/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonClientCallImpl.java @@ -47,7 +47,7 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; /** * This class serves as main implementation of {@link HttpJsonClientCall} for REST transport and is diff --git a/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonMetadata.java b/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonMetadata.java index 558217a9b0..e724134997 100644 --- a/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonMetadata.java +++ b/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonMetadata.java @@ -35,7 +35,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; @AutoValue @InternalExtensionOnly diff --git a/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpRequestRunnable.java b/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpRequestRunnable.java index 2738844bd0..5e49114334 100644 --- a/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpRequestRunnable.java +++ b/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpRequestRunnable.java @@ -55,7 +55,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; /** A runnable object that creates and executes an HTTP request. */ class HttpRequestRunnable implements Runnable { diff --git a/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/ManagedHttpJsonChannel.java b/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/ManagedHttpJsonChannel.java index 7a2e7a2f26..13f9cdf009 100644 --- a/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/ManagedHttpJsonChannel.java +++ b/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/ManagedHttpJsonChannel.java @@ -41,7 +41,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; /** Implementation of HttpJsonChannel which can issue http-json calls. */ public class ManagedHttpJsonChannel implements HttpJsonChannel, BackgroundResource { diff --git a/gax-java/gax/BUILD.bazel b/gax-java/gax/BUILD.bazel index 5dd3ff96bd..fd439e1c9e 100644 --- a/gax-java/gax/BUILD.bazel +++ b/gax-java/gax/BUILD.bazel @@ -15,7 +15,7 @@ _COMPILE_DEPS = [ "@com_google_auth_google_auth_library_oauth2_http//jar", "@com_google_auto_value_auto_value//jar", "@com_google_auto_value_auto_value_annotations//jar", - "@com_google_code_findbugs_jsr305//jar", + "@org_jspecify_jspecify//jar", "@com_google_errorprone_error_prone_annotations//jar", "@com_google_guava_guava//jar", "@io_opentelemetry_opentelemetry_api//jar", diff --git a/gax-java/gax/pom.xml b/gax-java/gax/pom.xml index 7b204e8a66..e4db79fb55 100644 --- a/gax-java/gax/pom.xml +++ b/gax-java/gax/pom.xml @@ -55,9 +55,9 @@ google-auth-library-oauth2-http - com.google.code.findbugs - jsr305 - provided + org.jspecify + jspecify + 1.0.0 org.graalvm.sdk diff --git a/gax-java/gax/src/main/java/com/google/api/gax/batching/BatchEntry.java b/gax-java/gax/src/main/java/com/google/api/gax/batching/BatchEntry.java index 163eae9fd6..c8342b5ab6 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/batching/BatchEntry.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/batching/BatchEntry.java @@ -32,7 +32,7 @@ import com.google.api.core.InternalApi; import com.google.api.core.SettableApiFuture; import com.google.auto.value.AutoValue; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; /** * This class contains the element and its corresponding unresolved future, which would be resolved diff --git a/gax-java/gax/src/main/java/com/google/api/gax/batching/Batcher.java b/gax-java/gax/src/main/java/com/google/api/gax/batching/Batcher.java index 6f9f878905..cc06572659 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/batching/Batcher.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/batching/Batcher.java @@ -34,7 +34,7 @@ import com.google.api.gax.rpc.ApiCallContext; import java.time.Duration; import java.util.concurrent.TimeoutException; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; /** * Represents a batching context where individual elements will be accumulated and flushed in a diff --git a/gax-java/gax/src/main/java/com/google/api/gax/batching/BatcherImpl.java b/gax-java/gax/src/main/java/com/google/api/gax/batching/BatcherImpl.java index 51549f70b3..1435fe8ed5 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/batching/BatcherImpl.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/batching/BatcherImpl.java @@ -64,8 +64,8 @@ import java.util.concurrent.TimeoutException; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; /** * Queues up the elements until {@link #flush()} is called; once batching is over, returned future @@ -500,7 +500,7 @@ void add( totalThrottledTimeMs += throttledTimeMs; } - void setResponseFuture(@Nonnull ApiFuture responseFuture) { + void setResponseFuture(@NonNull ApiFuture responseFuture) { Preconditions.checkNotNull(responseFuture); this.responseFuture = responseFuture; } diff --git a/gax-java/gax/src/main/java/com/google/api/gax/batching/BatcherStats.java b/gax-java/gax/src/main/java/com/google/api/gax/batching/BatcherStats.java index 20b0f95954..38e8839c48 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/batching/BatcherStats.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/batching/BatcherStats.java @@ -38,7 +38,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; /** * Keeps the statistics about failed operations(both at RPC and ElementT) in {@link Batcher}. This diff --git a/gax-java/gax/src/main/java/com/google/api/gax/batching/BatchingSettings.java b/gax-java/gax/src/main/java/com/google/api/gax/batching/BatchingSettings.java index 7507f6c284..54c4a61496 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/batching/BatchingSettings.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/batching/BatchingSettings.java @@ -37,7 +37,7 @@ import com.google.auto.value.AutoValue; import com.google.common.base.Preconditions; import java.time.Duration; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; /** * Represents the batching settings to use for an API method that is capable of batching. @@ -103,15 +103,13 @@ public abstract class BatchingSettings { public abstract Long getRequestByteThreshold(); /** This method is obsolete. Use {@link #getDelayThresholdDuration() } instead */ - @Nullable @ObsoleteApi("Use getDelayThresholdDuration() instead") - public org.threeten.bp.Duration getDelayThreshold() { + public org.threeten.bp.@Nullable Duration getDelayThreshold() { return toThreetenDuration(getDelayThresholdDuration()); } /** Get the delay threshold to use for batching. */ - @Nullable - public abstract java.time.Duration getDelayThresholdDuration(); + public abstract java.time.@Nullable Duration getDelayThresholdDuration(); /** Returns the Boolean object to indicate if the batching is enabled. Default to true */ public abstract Boolean getIsEnabled(); diff --git a/gax-java/gax/src/main/java/com/google/api/gax/batching/DynamicFlowControlSettings.java b/gax-java/gax/src/main/java/com/google/api/gax/batching/DynamicFlowControlSettings.java index 95025183a1..81910ec511 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/batching/DynamicFlowControlSettings.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/batching/DynamicFlowControlSettings.java @@ -33,7 +33,7 @@ import com.google.api.gax.batching.FlowController.LimitExceededBehavior; import com.google.auto.value.AutoValue; import com.google.common.base.Preconditions; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; /** Settings for dynamic flow control */ @AutoValue diff --git a/gax-java/gax/src/main/java/com/google/api/gax/batching/FlowControlEventStats.java b/gax-java/gax/src/main/java/com/google/api/gax/batching/FlowControlEventStats.java index 005b2bcedd..6f21b0a7aa 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/batching/FlowControlEventStats.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/batching/FlowControlEventStats.java @@ -36,7 +36,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; import java.util.concurrent.TimeUnit; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; /** * Record the statistics of flow control events. diff --git a/gax-java/gax/src/main/java/com/google/api/gax/batching/FlowControlSettings.java b/gax-java/gax/src/main/java/com/google/api/gax/batching/FlowControlSettings.java index b1634c2f65..f215d23820 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/batching/FlowControlSettings.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/batching/FlowControlSettings.java @@ -33,7 +33,7 @@ import com.google.api.gax.batching.FlowController.LimitExceededBehavior; import com.google.auto.value.AutoValue; import com.google.common.base.Preconditions; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; /** Settings for {@link FlowController}. */ @AutoValue @@ -88,11 +88,13 @@ public FlowControlSettings build() { Preconditions.checkArgument( settings.getMaxOutstandingElementCount() == null || settings.getMaxOutstandingElementCount() > 0, - "maxOutstandingElementCount limit is disabled by default, but if set it must be set to a value greater than 0."); + "maxOutstandingElementCount limit is disabled by default, but if set it must be set to a" + + " value greater than 0."); Preconditions.checkArgument( settings.getMaxOutstandingRequestBytes() == null || settings.getMaxOutstandingRequestBytes() > 0, - "maxOutstandingRequestBytes limit is disabled by default, but if set it must be set to a value greater than 0."); + "maxOutstandingRequestBytes limit is disabled by default, but if set it must be set to a" + + " value greater than 0."); return settings; } } diff --git a/gax-java/gax/src/main/java/com/google/api/gax/batching/FlowController.java b/gax-java/gax/src/main/java/com/google/api/gax/batching/FlowController.java index 00bf6988da..c97237695c 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/batching/FlowController.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/batching/FlowController.java @@ -34,7 +34,7 @@ import com.google.common.base.Preconditions; import com.google.common.base.Stopwatch; import java.util.concurrent.TimeUnit; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; /** Provides flow control capability. */ public class FlowController { diff --git a/gax-java/gax/src/main/java/com/google/api/gax/core/FixedCredentialsProvider.java b/gax-java/gax/src/main/java/com/google/api/gax/core/FixedCredentialsProvider.java index e95e113048..a609c2ef26 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/core/FixedCredentialsProvider.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/core/FixedCredentialsProvider.java @@ -31,7 +31,7 @@ import com.google.auth.Credentials; import com.google.auto.value.AutoValue; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; /** FixedCredentialsProvider is a CredentialsProvider which always provides the same credentials. */ @AutoValue diff --git a/gax-java/gax/src/main/java/com/google/api/gax/core/GoogleCredentialsProvider.java b/gax-java/gax/src/main/java/com/google/api/gax/core/GoogleCredentialsProvider.java index 56642ecdee..8259d76e72 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/core/GoogleCredentialsProvider.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/core/GoogleCredentialsProvider.java @@ -39,7 +39,7 @@ import com.google.common.collect.ImmutableList; import java.io.IOException; import java.util.List; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; /** * GoogleCredentialsProvider acquires credentials using Application Default Credentials. diff --git a/gax-java/gax/src/main/java/com/google/api/gax/retrying/NoopRetryingContext.java b/gax-java/gax/src/main/java/com/google/api/gax/retrying/NoopRetryingContext.java index 840918ed31..3529c52a95 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/retrying/NoopRetryingContext.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/retrying/NoopRetryingContext.java @@ -36,7 +36,7 @@ import com.google.api.gax.tracing.ApiTracer; import com.google.api.gax.tracing.BaseApiTracer; import java.util.Set; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; /** * Backwards compatibility class to aid in transition to adding operation state to {@link @@ -48,7 +48,7 @@ public static RetryingContext create() { } /** {@inheritDoc} */ - @Nonnull + @NonNull @Override public ApiTracer getTracer() { return BaseApiTracer.getInstance(); diff --git a/gax-java/gax/src/main/java/com/google/api/gax/retrying/RetryingContext.java b/gax-java/gax/src/main/java/com/google/api/gax/retrying/RetryingContext.java index 6db53c4e25..263ff293af 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/retrying/RetryingContext.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/retrying/RetryingContext.java @@ -33,8 +33,8 @@ import com.google.api.gax.rpc.StatusCode; import com.google.api.gax.tracing.ApiTracer; import java.util.Set; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; /** * Context for a retryable operation. @@ -44,7 +44,7 @@ @BetaApi("The surface for passing per operation state is not yet stable") public interface RetryingContext { /** Returns the {@link ApiTracer} associated with the current operation. */ - @Nonnull + @NonNull ApiTracer getTracer(); /** diff --git a/gax-java/gax/src/main/java/com/google/api/gax/retrying/RetryingExecutorWithContext.java b/gax-java/gax/src/main/java/com/google/api/gax/retrying/RetryingExecutorWithContext.java index f19ba56079..fb9200edbc 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/retrying/RetryingExecutorWithContext.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/retrying/RetryingExecutorWithContext.java @@ -32,7 +32,7 @@ import com.google.api.core.BetaApi; import com.google.api.core.InternalExtensionOnly; import java.util.concurrent.Callable; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; /** * A {@link RetryingExecutor} that accepts a per-operation context. @@ -45,5 +45,5 @@ @InternalExtensionOnly public interface RetryingExecutorWithContext extends RetryingExecutor { RetryingFuture createFuture( - @Nonnull Callable callable, @Nonnull RetryingContext context); + @NonNull Callable callable, @NonNull RetryingContext context); } diff --git a/gax-java/gax/src/main/java/com/google/api/gax/retrying/StreamResumptionStrategy.java b/gax-java/gax/src/main/java/com/google/api/gax/retrying/StreamResumptionStrategy.java index 227b4b0ce4..9fcdd08cd5 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/retrying/StreamResumptionStrategy.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/retrying/StreamResumptionStrategy.java @@ -29,8 +29,8 @@ */ package com.google.api.gax.retrying; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; /** * This is part of the server streaming retry api. Its implementers are responsible for tracking the @@ -41,7 +41,7 @@ public interface StreamResumptionStrategy { /** Creates a new instance of this StreamResumptionStrategy without accumulated state */ - @Nonnull + @NonNull StreamResumptionStrategy createNew(); /** @@ -58,7 +58,7 @@ public interface StreamResumptionStrategy { * through this method. * */ - @Nonnull + @NonNull ResponseT processResponse(ResponseT response); /** diff --git a/gax-java/gax/src/main/java/com/google/api/gax/rpc/ApiCallContext.java b/gax-java/gax/src/main/java/com/google/api/gax/rpc/ApiCallContext.java index 4ad517f4b3..4a034a6327 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/rpc/ApiCallContext.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/rpc/ApiCallContext.java @@ -41,8 +41,8 @@ import java.util.List; import java.util.Map; import java.util.Set; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; /** * Context for an API call. @@ -64,11 +64,11 @@ public interface ApiCallContext extends RetryingContext { ApiCallContext withTransportChannel(TransportChannel channel); /** Returns a new ApiCallContext with the given Endpoint Context. */ - ApiCallContext withEndpointContext(EndpointContext endpointContext); + ApiCallContext withEndpointContext(@Nullable EndpointContext endpointContext); /** This method is obsolete. Use {@link #withTimeoutDuration(java.time.Duration)} instead. */ @ObsoleteApi("Use withTimeoutDuration(java.time.Duration) instead") - ApiCallContext withTimeout(@Nullable org.threeten.bp.Duration timeout); + ApiCallContext withTimeout(org.threeten.bp.@Nullable Duration timeout); /** * Returns a new ApiCallContext with the given timeout set. @@ -82,23 +82,21 @@ public interface ApiCallContext extends RetryingContext { *

If a method has default {@link com.google.api.gax.retrying.RetrySettings}, the max attempts * and/or total timeout is still respected when scheduling each RPC attempt. */ - ApiCallContext withTimeoutDuration(@Nullable java.time.Duration timeout); + ApiCallContext withTimeoutDuration(java.time.@Nullable Duration timeout); /** This method is obsolete. Use {@link #getTimeoutDuration()} instead. */ - @Nullable @ObsoleteApi("Use getTimeoutDuration() instead") - org.threeten.bp.Duration getTimeout(); + org.threeten.bp.@Nullable Duration getTimeout(); /** Returns the configured per-RPC timeout. */ - @Nullable - java.time.Duration getTimeoutDuration(); + java.time.@Nullable Duration getTimeoutDuration(); /** * This method is obsolete. Use {@link #withStreamWaitTimeoutDuration(java.time.Duration)} * instead. */ @ObsoleteApi("Use withStreamWaitTimeoutDuration(java.time.Duration) instead") - ApiCallContext withStreamWaitTimeout(@Nullable org.threeten.bp.Duration streamWaitTimeout); + ApiCallContext withStreamWaitTimeout(org.threeten.bp.@Nullable Duration streamWaitTimeout); /** * Returns a new ApiCallContext with the given stream timeout set. @@ -117,27 +115,25 @@ public interface ApiCallContext extends RetryingContext { *

Please note that this timeout is best effort and the maximum resolution is configured in * {@link StubSettings#getStreamWatchdogCheckIntervalDuration()}. */ - ApiCallContext withStreamWaitTimeoutDuration(@Nullable java.time.Duration streamWaitTimeout); + ApiCallContext withStreamWaitTimeoutDuration(java.time.@Nullable Duration streamWaitTimeout); /** This method is obsolete. Use {@link #getStreamWaitTimeoutDuration()} instead. */ - @Nullable @ObsoleteApi("Use getStreamWaitTimeoutDuration() instead") - org.threeten.bp.Duration getStreamWaitTimeout(); + org.threeten.bp.@Nullable Duration getStreamWaitTimeout(); /** * Return the stream wait timeout set for this context. * * @see #withStreamWaitTimeoutDuration(java.time.Duration) */ - @Nullable - java.time.Duration getStreamWaitTimeoutDuration(); + java.time.@Nullable Duration getStreamWaitTimeoutDuration(); /** * This method is obsolete. Use {@link #withStreamIdleTimeoutDuration(java.time.Duration)} * instead. */ @ObsoleteApi("Use withStreamIdleTimeoutDuration(java.time.Duration) instead") - ApiCallContext withStreamIdleTimeout(@Nullable org.threeten.bp.Duration streamIdleTimeout); + ApiCallContext withStreamIdleTimeout(org.threeten.bp.@Nullable Duration streamIdleTimeout); /** * Returns a new ApiCallContext with the given stream idle timeout set. @@ -157,20 +153,19 @@ public interface ApiCallContext extends RetryingContext { *

Please note that this timeout is best effort and the maximum resolution is configured in * {@link StubSettings#getStreamWatchdogCheckIntervalDuration()}. */ - ApiCallContext withStreamIdleTimeoutDuration(@Nullable java.time.Duration streamIdleTimeout); + ApiCallContext withStreamIdleTimeoutDuration(java.time.@Nullable Duration streamIdleTimeout); /** This method is obsolete. Use {@link #getStreamIdleTimeoutDuration()} instead. */ - @Nullable @ObsoleteApi("Use getStreamIdleTimeoutDuration() instead") - org.threeten.bp.Duration getStreamIdleTimeout(); + org.threeten.bp.@Nullable Duration getStreamIdleTimeout(); /** * The stream idle timeout set for this context. * * @see #withStreamIdleTimeoutDuration(java.time.Duration) */ - @Nullable - java.time.Duration getStreamIdleTimeoutDuration(); + java.time.@Nullable Duration getStreamIdleTimeoutDuration(); + /** * The {@link ApiTracer} that was previously set for this context. * @@ -178,7 +173,7 @@ public interface ApiCallContext extends RetryingContext { * events like retries. */ @BetaApi("The surface for tracing is not stable yet and may change in the future") - @Nonnull + @NonNull ApiTracer getTracer(); /** @@ -190,7 +185,7 @@ public interface ApiCallContext extends RetryingContext { * @param tracer the {@link ApiTracer} to set. */ @BetaApi("The surface for tracing is not stable yet and may change in the future") - ApiCallContext withTracer(@Nonnull ApiTracer tracer); + ApiCallContext withTracer(@NonNull ApiTracer tracer); /** * Returns a new ApiCallContext with the given {@link RetrySettings} set. diff --git a/gax-java/gax/src/main/java/com/google/api/gax/rpc/ClientContext.java b/gax-java/gax/src/main/java/com/google/api/gax/rpc/ClientContext.java index 5bce1ac6bb..673e40ffcd 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/rpc/ClientContext.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/rpc/ClientContext.java @@ -61,8 +61,8 @@ import java.util.Set; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; /** * Encapsulates client state, including executor, credentials, and transport channel. @@ -104,14 +104,12 @@ public abstract class ClientContext { public abstract Watchdog getStreamWatchdog(); /** This method is obsolete. Use {@link #getStreamWatchdogCheckIntervalDuration()} instead. */ - @Nonnull @ObsoleteApi("Use getStreamWatchdogCheckIntervalDuration() instead") - public final org.threeten.bp.Duration getStreamWatchdogCheckInterval() { + public final org.threeten.bp.@NonNull Duration getStreamWatchdogCheckInterval() { return toThreetenDuration(getStreamWatchdogCheckIntervalDuration()); } - @Nonnull - public abstract java.time.Duration getStreamWatchdogCheckIntervalDuration(); + public abstract java.time.@NonNull Duration getStreamWatchdogCheckIntervalDuration(); @Nullable public abstract String getUniverseDomain(); @@ -127,7 +125,7 @@ public final org.threeten.bp.Duration getStreamWatchdogCheckInterval() { /** Gets the {@link ApiTracerFactory} that will be used to generate traces for operations. */ @BetaApi("The surface for tracing is not stable yet and may change in the future.") - @Nonnull + @NonNull public abstract ApiTracerFactory getTracerFactory(); /** diff --git a/gax-java/gax/src/main/java/com/google/api/gax/rpc/ClientSettings.java b/gax-java/gax/src/main/java/com/google/api/gax/rpc/ClientSettings.java index 234fd4d19d..90c972df7a 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/rpc/ClientSettings.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/rpc/ClientSettings.java @@ -39,8 +39,8 @@ import com.google.common.base.MoreObjects; import java.io.IOException; import java.util.concurrent.Executor; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; /** * A base settings class to configure a client class. @@ -118,14 +118,12 @@ public final String getApiKey() { } /** This method is obsolete. Use {@link #getWatchdogCheckIntervalDuration()} instead. */ - @Nonnull @ObsoleteApi("Use getWatchdogCheckIntervalDuration() instead") - public final org.threeten.bp.Duration getWatchdogCheckInterval() { + public final org.threeten.bp.@NonNull Duration getWatchdogCheckInterval() { return stubSettings.getStreamWatchdogCheckInterval(); } - @Nonnull - public final java.time.Duration getWatchdogCheckIntervalDuration() { + public final java.time.@NonNull Duration getWatchdogCheckIntervalDuration() { return stubSettings.getStreamWatchdogCheckIntervalDuration(); } @@ -287,11 +285,11 @@ public B setWatchdogProvider(@Nullable WatchdogProvider watchdogProvider) { * instead. */ @ObsoleteApi("Use setWatchdogCheckIntervalDuration(java.time.Duration) instead") - public B setWatchdogCheckInterval(@Nullable org.threeten.bp.Duration checkInterval) { + public B setWatchdogCheckInterval(org.threeten.bp.@Nullable Duration checkInterval) { return setWatchdogCheckIntervalDuration(toJavaTimeDuration(checkInterval)); } - public B setWatchdogCheckIntervalDuration(@Nullable java.time.Duration checkInterval) { + public B setWatchdogCheckIntervalDuration(java.time.@Nullable Duration checkInterval) { stubSettings.setStreamWatchdogCheckIntervalDuration(checkInterval); return self(); } @@ -391,14 +389,12 @@ public String getApiKey() { } /** This method is obsolete. Use {@link #getWatchdogCheckIntervalDuration()} instead */ - @Nullable @ObsoleteApi("Use getWatchdogCheckIntervalDuration() instead") - public org.threeten.bp.Duration getWatchdogCheckInterval() { + public org.threeten.bp.@Nullable Duration getWatchdogCheckInterval() { return stubSettings.getStreamWatchdogCheckInterval(); } - @Nullable - public java.time.Duration getWatchdogCheckIntervalDuration() { + public java.time.@Nullable Duration getWatchdogCheckIntervalDuration() { return stubSettings.getStreamWatchdogCheckIntervalDuration(); } diff --git a/gax-java/gax/src/main/java/com/google/api/gax/rpc/EndpointContext.java b/gax-java/gax/src/main/java/com/google/api/gax/rpc/EndpointContext.java index dd6c199b35..7c85b6b281 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/rpc/EndpointContext.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/rpc/EndpointContext.java @@ -37,7 +37,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Strings; import java.io.IOException; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; /** * EndpointContext is an internal class used by the client library to resolve the endpoint. It is @@ -62,7 +62,9 @@ public abstract class EndpointContext { public static final String GOOGLE_CLOUD_UNIVERSE_DOMAIN = "GOOGLE_CLOUD_UNIVERSE_DOMAIN"; public static final String INVALID_UNIVERSE_DOMAIN_ERROR_TEMPLATE = - "The configured universe domain (%s) does not match the universe domain found in the credentials (%s). If you haven't configured the universe domain explicitly, `googleapis.com` is the default."; + "The configured universe domain (%s) does not match the universe domain found in the" + + " credentials (%s). If you haven't configured the universe domain explicitly," + + " `googleapis.com` is the default."; public static final String UNABLE_TO_RETRIEVE_CREDENTIALS_ERROR_MESSAGE = "Unable to retrieve the Universe Domain from the Credentials."; diff --git a/gax-java/gax/src/main/java/com/google/api/gax/rpc/ErrorDetails.java b/gax-java/gax/src/main/java/com/google/api/gax/rpc/ErrorDetails.java index 45ba427b6e..b7d799577f 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/rpc/ErrorDetails.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/rpc/ErrorDetails.java @@ -45,7 +45,7 @@ import com.google.rpc.ResourceInfo; import com.google.rpc.RetryInfo; import java.util.List; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; /** This class contains a list of standard error messages that returns from server. */ @AutoValue diff --git a/gax-java/gax/src/main/java/com/google/api/gax/rpc/FixedHeaderProvider.java b/gax-java/gax/src/main/java/com/google/api/gax/rpc/FixedHeaderProvider.java index 8aa7816972..e023b4420f 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/rpc/FixedHeaderProvider.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/rpc/FixedHeaderProvider.java @@ -36,7 +36,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; /** An instance of HeaderProvider that always provides the same headers. */ @AutoValue diff --git a/gax-java/gax/src/main/java/com/google/api/gax/rpc/FixedWatchdogProvider.java b/gax-java/gax/src/main/java/com/google/api/gax/rpc/FixedWatchdogProvider.java index 170e820c03..ead51b317c 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/rpc/FixedWatchdogProvider.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/rpc/FixedWatchdogProvider.java @@ -34,8 +34,8 @@ import com.google.api.core.ObsoleteApi; import java.time.Duration; import java.util.concurrent.ScheduledExecutorService; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; /** * A watchdog provider which always returns the same watchdog instance provided to the provider @@ -62,7 +62,7 @@ public boolean needsClock() { } @Override - public WatchdogProvider withClock(@Nonnull ApiClock clock) { + public WatchdogProvider withClock(@NonNull ApiClock clock) { throw new UnsupportedOperationException("FixedWatchdogProvider doesn't need a clock"); } diff --git a/gax-java/gax/src/main/java/com/google/api/gax/rpc/InstantiatingWatchdogProvider.java b/gax-java/gax/src/main/java/com/google/api/gax/rpc/InstantiatingWatchdogProvider.java index 5b06f882a3..1fa3beb4e9 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/rpc/InstantiatingWatchdogProvider.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/rpc/InstantiatingWatchdogProvider.java @@ -36,8 +36,8 @@ import com.google.api.core.ObsoleteApi; import com.google.common.base.Preconditions; import java.util.concurrent.ScheduledExecutorService; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; /** * A watchdog provider which instantiates a new provider on every request. @@ -49,7 +49,7 @@ public final class InstantiatingWatchdogProvider implements WatchdogProvider { @Nullable private final ApiClock clock; @Nullable private final ScheduledExecutorService executor; - @Nullable private final java.time.Duration checkInterval; + private final java.time.@Nullable Duration checkInterval; public static WatchdogProvider create() { return new InstantiatingWatchdogProvider(null, null, null); @@ -58,7 +58,7 @@ public static WatchdogProvider create() { private InstantiatingWatchdogProvider( @Nullable ApiClock clock, @Nullable ScheduledExecutorService executor, - @Nullable java.time.Duration checkInterval) { + java.time.@Nullable Duration checkInterval) { this.clock = clock; this.executor = executor; this.checkInterval = checkInterval; @@ -70,7 +70,7 @@ public boolean needsClock() { } @Override - public WatchdogProvider withClock(@Nonnull ApiClock clock) { + public WatchdogProvider withClock(@NonNull ApiClock clock) { return new InstantiatingWatchdogProvider( Preconditions.checkNotNull(clock), executor, checkInterval); } @@ -85,12 +85,12 @@ public boolean needsCheckInterval() { */ @Override @ObsoleteApi("Use withCheckIntervalDuration(java.time.Duration) instead") - public WatchdogProvider withCheckInterval(@Nonnull org.threeten.bp.Duration checkInterval) { + public WatchdogProvider withCheckInterval(org.threeten.bp.@NonNull Duration checkInterval) { return withCheckIntervalDuration(toJavaTimeDuration(checkInterval)); } @Override - public WatchdogProvider withCheckIntervalDuration(@Nonnull java.time.Duration checkInterval) { + public WatchdogProvider withCheckIntervalDuration(java.time.@NonNull Duration checkInterval) { return new InstantiatingWatchdogProvider( clock, executor, Preconditions.checkNotNull(checkInterval)); } diff --git a/gax-java/gax/src/main/java/com/google/api/gax/rpc/ServerStream.java b/gax-java/gax/src/main/java/com/google/api/gax/rpc/ServerStream.java index d1f9848631..2700a0a1f1 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/rpc/ServerStream.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/rpc/ServerStream.java @@ -33,7 +33,7 @@ import java.util.Iterator; import java.util.stream.Stream; import java.util.stream.StreamSupport; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; /** * A blocking Iterable-style wrapper around server stream responses. @@ -81,7 +81,7 @@ ResponseObserver observer() { /** {@inheritDoc} */ @Override - @Nonnull + @NonNull public Iterator iterator() { if (consumed) { throw new IllegalStateException("Iterator already consumed"); diff --git a/gax-java/gax/src/main/java/com/google/api/gax/rpc/ServerStreamingCallSettings.java b/gax-java/gax/src/main/java/com/google/api/gax/rpc/ServerStreamingCallSettings.java index cbba46485f..6a08a765e3 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/rpc/ServerStreamingCallSettings.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/rpc/ServerStreamingCallSettings.java @@ -43,7 +43,7 @@ import com.google.common.collect.Sets; import java.time.Duration; import java.util.Set; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; /** * A settings class to configure a {@link ServerStreamingCallable}. @@ -80,12 +80,12 @@ public final class ServerStreamingCallSettings extends StreamingCallSettings { - @Nonnull private final Set retryableCodes; - @Nonnull private final RetrySettings retrySettings; - @Nonnull private final StreamResumptionStrategy resumptionStrategy; + @NonNull private final Set retryableCodes; + @NonNull private final RetrySettings retrySettings; + @NonNull private final StreamResumptionStrategy resumptionStrategy; - @Nonnull private final java.time.Duration idleTimeout; - @Nonnull private final java.time.Duration waitTimeout; + private final java.time.@NonNull Duration idleTimeout; + private final java.time.@NonNull Duration waitTimeout; private ServerStreamingCallSettings(Builder builder) { this.retryableCodes = ImmutableSet.copyOf(builder.retryableCodes); @@ -99,7 +99,7 @@ private ServerStreamingCallSettings(Builder builder) { * See the class documentation of {@link ServerStreamingCallSettings} for a description of what * retryableCodes do. */ - @Nonnull + @NonNull public Set getRetryableCodes() { return retryableCodes; } @@ -108,7 +108,7 @@ public Set getRetryableCodes() { * See the class documentation of {@link ServerStreamingCallSettings} for a description of what * retrySettings do. */ - @Nonnull + @NonNull public RetrySettings getRetrySettings() { return retrySettings; } @@ -117,15 +117,14 @@ public RetrySettings getRetrySettings() { * See the class documentation of {@link ServerStreamingCallSettings} and {@link * StreamResumptionStrategy} for a description of what the StreamResumptionStrategy does. */ - @Nonnull + @NonNull public StreamResumptionStrategy getResumptionStrategy() { return resumptionStrategy; } /** This method is obsolete. Use {@link #getIdleTimeoutDuration()} instead. */ - @Nonnull @ObsoleteApi("Use getIdleTimeoutDuration() instead") - public org.threeten.bp.Duration getIdleTimeout() { + public org.threeten.bp.@NonNull Duration getIdleTimeout() { return toThreetenDuration(getIdleTimeoutDuration()); } @@ -133,15 +132,13 @@ public org.threeten.bp.Duration getIdleTimeout() { * See the class documentation of {@link ServerStreamingCallSettings} for a description of what * the {@link #idleTimeout} does. */ - @Nonnull - public java.time.Duration getIdleTimeoutDuration() { + public java.time.@NonNull Duration getIdleTimeoutDuration() { return idleTimeout; } /** This method is obsolete. Use {@link #getWaitTimeoutDuration()} instead. */ - @Nonnull @ObsoleteApi("Use getWaitTimeoutDuration() instead") - public org.threeten.bp.Duration getWaitTimeout() { + public org.threeten.bp.@NonNull Duration getWaitTimeout() { return toThreetenDuration(getWaitTimeoutDuration()); } @@ -149,8 +146,7 @@ public org.threeten.bp.Duration getWaitTimeout() { * See the class documentation of {@link ServerStreamingCallSettings} for a description of what * the {@link #waitTimeout} does. */ - @Nonnull - public java.time.Duration getWaitTimeoutDuration() { + public java.time.@NonNull Duration getWaitTimeoutDuration() { return waitTimeout; } @@ -174,13 +170,13 @@ public String toString() { public static class Builder extends StreamingCallSettings.Builder { - @Nonnull private Set retryableCodes; - @Nonnull private RetrySettings.Builder retrySettingsBuilder; - @Nonnull private StreamResumptionStrategy resumptionStrategy; + @NonNull private Set retryableCodes; + private RetrySettings.@NonNull Builder retrySettingsBuilder; + @NonNull private StreamResumptionStrategy resumptionStrategy; - @Nonnull private java.time.Duration idleTimeout; + private java.time.@NonNull Duration idleTimeout; - @Nonnull private java.time.Duration waitTimeout; + private java.time.@NonNull Duration waitTimeout; /** Initialize the builder with default settings */ private Builder() { @@ -221,7 +217,7 @@ public Builder setRetryableCodes(Set retryableCodes) return this; } - @Nonnull + @NonNull public Set getRetryableCodes() { return retryableCodes; } @@ -249,13 +245,13 @@ public RetrySettings.Builder retrySettings() { * * @see #retrySettings() */ - public Builder setRetrySettings(@Nonnull RetrySettings retrySettings) { + public Builder setRetrySettings(@NonNull RetrySettings retrySettings) { Preconditions.checkNotNull(retrySettings); this.retrySettingsBuilder = retrySettings.toBuilder(); return this; } - @Nonnull + @NonNull public RetrySettings getRetrySettings() { return retrySettingsBuilder.build(); } @@ -266,13 +262,13 @@ public RetrySettings getRetrySettings() { */ @ObsoleteApi("Use setSimpleTimeoutNoRetriesDuration(java.time.Duration) instead") public Builder setSimpleTimeoutNoRetries( - @Nonnull org.threeten.bp.Duration timeout) { + org.threeten.bp.@NonNull Duration timeout) { return setSimpleTimeoutNoRetriesDuration(toJavaTimeDuration(timeout)); } /** Disables retries and sets the overall timeout. */ public Builder setSimpleTimeoutNoRetriesDuration( - @Nonnull java.time.Duration timeout) { + java.time.@NonNull Duration timeout) { setRetryableCodes(); setRetrySettings( RetrySettings.newBuilder() @@ -294,33 +290,31 @@ public Builder setSimpleTimeoutNoRetriesDuration( * StreamResumptionStrategy does. */ public Builder setResumptionStrategy( - @Nonnull StreamResumptionStrategy resumptionStrategy) { + @NonNull StreamResumptionStrategy resumptionStrategy) { Preconditions.checkNotNull(resumptionStrategy); this.resumptionStrategy = Preconditions.checkNotNull(resumptionStrategy); return this; } - @Nonnull + @NonNull public StreamResumptionStrategy getResumptionStrategy() { return resumptionStrategy; } /** This method is obsolete. Use {@link #getIdleTimeoutDuration()} instead. */ - @Nonnull @ObsoleteApi("Use getIdleTimeoutDuration() instead") - public org.threeten.bp.Duration getIdleTimeout() { + public org.threeten.bp.@NonNull Duration getIdleTimeout() { return toThreetenDuration(getIdleTimeoutDuration()); } - @Nonnull - public java.time.Duration getIdleTimeoutDuration() { + public java.time.@NonNull Duration getIdleTimeoutDuration() { return idleTimeout; } /** This method is obsolete. Use {@link #setIdleTimeoutDuration(Duration)} instead. */ @ObsoleteApi("Use setIdleTimeoutDuration(java.time.Duration) instead") public Builder setIdleTimeout( - @Nonnull org.threeten.bp.Duration idleTimeout) { + org.threeten.bp.@NonNull Duration idleTimeout) { return setIdleTimeoutDuration(toJavaTimeDuration(idleTimeout)); } @@ -329,27 +323,25 @@ public Builder setIdleTimeout( * {@link java.time.Duration#ZERO} disables the check for abandoned streams. */ public Builder setIdleTimeoutDuration( - @Nonnull java.time.Duration idleTimeout) { + java.time.@NonNull Duration idleTimeout) { this.idleTimeout = Preconditions.checkNotNull(idleTimeout); return this; } /** This method is obsolete. Use {@link #getWaitTimeoutDuration()} instead. */ - @Nonnull @ObsoleteApi("Use getWaitTimeoutDuration() instead") - public org.threeten.bp.Duration getWaitTimeout() { + public org.threeten.bp.@NonNull Duration getWaitTimeout() { return toThreetenDuration(getWaitTimeoutDuration()); } - @Nonnull - public java.time.Duration getWaitTimeoutDuration() { + public java.time.@NonNull Duration getWaitTimeoutDuration() { return waitTimeout; } /** This method is obsolete. Use {@link #setWaitTimeoutDuration(java.time.Duration)} instead. */ @ObsoleteApi("Use setWaitTimeoutDuration(java.time.Duration) instead") public Builder setWaitTimeout( - @Nonnull org.threeten.bp.Duration waitTimeout) { + org.threeten.bp.@NonNull Duration waitTimeout) { return setWaitTimeoutDuration(toJavaTimeDuration(waitTimeout)); } @@ -358,7 +350,7 @@ public Builder setWaitTimeout( * java.time.Duration#ZERO} disables the check for abandoned streams. */ public Builder setWaitTimeoutDuration( - @Nonnull java.time.Duration waitTimeout) { + java.time.@NonNull Duration waitTimeout) { this.waitTimeout = waitTimeout; return this; } diff --git a/gax-java/gax/src/main/java/com/google/api/gax/rpc/StubSettings.java b/gax-java/gax/src/main/java/com/google/api/gax/rpc/StubSettings.java index 03c9519e38..92ee128f85 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/rpc/StubSettings.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/rpc/StubSettings.java @@ -51,8 +51,8 @@ import com.google.common.base.Preconditions; import java.io.IOException; import java.util.concurrent.Executor; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; /** * A base settings class to configure a client stub class. @@ -77,11 +77,11 @@ public abstract class StubSettings> { private final String quotaProjectId; @Nullable private final String gdchApiAudience; @Nullable private final WatchdogProvider streamWatchdogProvider; - @Nonnull private final java.time.Duration streamWatchdogCheckInterval; - @Nonnull private final ApiTracerFactory tracerFactory; + private final java.time.@NonNull Duration streamWatchdogCheckInterval; + @NonNull private final ApiTracerFactory tracerFactory; // Track if deprecated setExecutorProvider is called private boolean deprecatedExecutorProviderSet; - @Nonnull private final EndpointContext endpointContext; + @NonNull private final EndpointContext endpointContext; private final String apiKey; /** @@ -209,14 +209,12 @@ public final WatchdogProvider getStreamWatchdogProvider() { } /** This method is obsolete. Use {@link #getStreamWatchdogCheckIntervalDuration()} instead. */ - @Nonnull @ObsoleteApi("Use getStreamWatchdogCheckIntervalDuration() instead") - public final org.threeten.bp.Duration getStreamWatchdogCheckInterval() { + public final org.threeten.bp.@NonNull Duration getStreamWatchdogCheckInterval() { return toThreetenDuration(getStreamWatchdogCheckIntervalDuration()); } - @Nonnull - public final java.time.Duration getStreamWatchdogCheckIntervalDuration() { + public final java.time.@NonNull Duration getStreamWatchdogCheckIntervalDuration() { return streamWatchdogCheckInterval; } @@ -225,7 +223,7 @@ public final java.time.Duration getStreamWatchdogCheckIntervalDuration() { * operations. */ @BetaApi("The surface for tracing is not stable yet and may change in the future.") - @Nonnull + @NonNull public ApiTracerFactory getTracerFactory() { return tracerFactory; } @@ -280,8 +278,8 @@ public abstract static class Builder< private String quotaProjectId; @Nullable private String gdchApiAudience; @Nullable private WatchdogProvider streamWatchdogProvider; - @Nonnull private java.time.Duration streamWatchdogCheckInterval; - @Nonnull private ApiTracerFactory tracerFactory; + private java.time.@NonNull Duration streamWatchdogCheckInterval; + @NonNull private ApiTracerFactory tracerFactory; private boolean deprecatedExecutorProviderSet; private String universeDomain; private final EndpointContext endpointContext; @@ -547,7 +545,7 @@ public B setQuotaProjectId(String quotaProjectId) { * #setStreamWatchdogCheckIntervalDuration(java.time.Duration)} instead. */ @ObsoleteApi("Use setStreamWatchdogCheckIntervalDuration(java.time.Duration) instead") - public B setStreamWatchdogCheckInterval(@Nonnull org.threeten.bp.Duration checkInterval) { + public B setStreamWatchdogCheckInterval(org.threeten.bp.@NonNull Duration checkInterval) { return setStreamWatchdogCheckIntervalDuration(toJavaTimeDuration(checkInterval)); } @@ -555,7 +553,7 @@ public B setStreamWatchdogCheckInterval(@Nonnull org.threeten.bp.Duration checkI * Sets how often the {@link Watchdog} will check ongoing streaming RPCs. Defaults to 10 secs. * Use {@link java.time.Duration#ZERO} to disable. */ - public B setStreamWatchdogCheckIntervalDuration(@Nonnull java.time.Duration checkInterval) { + public B setStreamWatchdogCheckIntervalDuration(java.time.@NonNull Duration checkInterval) { Preconditions.checkNotNull(checkInterval); this.streamWatchdogCheckInterval = checkInterval; return self(); @@ -579,7 +577,7 @@ public B setGdchApiAudience(String gdchApiAudience) { * @param tracerFactory an instance of {@link ApiTracerFactory} to set. */ @BetaApi("The surface for tracing is not stable yet and may change in the future.") - public B setTracerFactory(@Nonnull ApiTracerFactory tracerFactory) { + public B setTracerFactory(@NonNull ApiTracerFactory tracerFactory) { Preconditions.checkNotNull(tracerFactory); this.tracerFactory = tracerFactory; return self(); @@ -677,13 +675,12 @@ public org.threeten.bp.Duration getStreamWatchdogCheckInterval() { return toThreetenDuration(getStreamWatchdogCheckIntervalDuration()); } - @Nonnull - public java.time.Duration getStreamWatchdogCheckIntervalDuration() { + public java.time.@NonNull Duration getStreamWatchdogCheckIntervalDuration() { return Preconditions.checkNotNull(streamWatchdogCheckInterval); } @BetaApi("The surface for tracing is not stable yet and may change in the future.") - @Nonnull + @NonNull public ApiTracerFactory getTracerFactory() { return tracerFactory; } diff --git a/gax-java/gax/src/main/java/com/google/api/gax/rpc/Watchdog.java b/gax-java/gax/src/main/java/com/google/api/gax/rpc/Watchdog.java index 69ca5d1eca..b86aa5e99d 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/rpc/Watchdog.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/rpc/Watchdog.java @@ -49,7 +49,7 @@ import java.util.concurrent.TimeoutException; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; /** * Prevents the streams from hanging indefinitely. This middleware garbage collects idle streams in @@ -120,16 +120,17 @@ private void start() { "Use watchDuration(ResponseObserver, java.time.Duration, java.time.Duration) instead") public ResponseObserver watch( ResponseObserver innerObserver, - @Nonnull org.threeten.bp.Duration waitTimeout, - @Nonnull org.threeten.bp.Duration idleTimeout) { + org.threeten.bp.@NonNull Duration waitTimeout, + org.threeten.bp.@NonNull Duration idleTimeout) { return watchDuration( innerObserver, toJavaTimeDuration(waitTimeout), toJavaTimeDuration(idleTimeout)); } + /** Wraps the target observer with timing constraints. */ public ResponseObserver watchDuration( ResponseObserver innerObserver, - @Nonnull java.time.Duration waitTimeout, - @Nonnull java.time.Duration idleTimeout) { + java.time.@NonNull Duration waitTimeout, + java.time.@NonNull Duration idleTimeout) { Preconditions.checkNotNull(innerObserver, "innerObserver can't be null"); Preconditions.checkNotNull(waitTimeout, "waitTimeout can't be null"); Preconditions.checkNotNull(idleTimeout, "idleTimeout can't be null"); diff --git a/gax-java/gax/src/main/java/com/google/api/gax/rpc/WatchdogProvider.java b/gax-java/gax/src/main/java/com/google/api/gax/rpc/WatchdogProvider.java index a31fc7b6f4..6a92e7bf51 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/rpc/WatchdogProvider.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/rpc/WatchdogProvider.java @@ -34,12 +34,12 @@ import com.google.api.core.ApiClock; import com.google.api.core.ObsoleteApi; import java.util.concurrent.ScheduledExecutorService; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; public interface WatchdogProvider { boolean needsClock(); - WatchdogProvider withClock(@Nonnull ApiClock clock); + WatchdogProvider withClock(@NonNull ApiClock clock); boolean needsCheckInterval(); diff --git a/gax-java/gax/src/main/java/com/google/api/gax/tracing/MetricsTracer.java b/gax-java/gax/src/main/java/com/google/api/gax/tracing/MetricsTracer.java index 279d375be5..a089e955f3 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/tracing/MetricsTracer.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/tracing/MetricsTracer.java @@ -44,7 +44,7 @@ import java.util.concurrent.CancellationException; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; /** * This class computes generic metrics that can be observed in the lifecycle of an RPC operation. diff --git a/gax-java/gax/src/main/java/com/google/api/gax/tracing/OpencensusTracer.java b/gax-java/gax/src/main/java/com/google/api/gax/tracing/OpencensusTracer.java index c9f6b7cfc7..f8e6c493c5 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/tracing/OpencensusTracer.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/tracing/OpencensusTracer.java @@ -49,7 +49,7 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.atomic.AtomicLong; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; /** * Implementation of {@link ApiTracer} that uses OpenCensus. @@ -222,7 +222,7 @@ public class OpencensusTracer extends BaseApiTracer { private long totalReceivedMessages = 0; OpencensusTracer( - @Nonnull Tracer tracer, @Nonnull Span span, @Nonnull OperationType operationType) { + @NonNull Tracer tracer, @NonNull Span span, @NonNull OperationType operationType) { this.tracer = Preconditions.checkNotNull(tracer, "tracer can't be null"); this.span = Preconditions.checkNotNull(span, "span can't be null"); this.operationType = Preconditions.checkNotNull(operationType, "operationType can't be null"); diff --git a/gax-java/gax/src/main/java/com/google/api/gax/tracing/OpencensusTracerFactory.java b/gax-java/gax/src/main/java/com/google/api/gax/tracing/OpencensusTracerFactory.java index b9966b1f51..81434a1ac4 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/tracing/OpencensusTracerFactory.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/tracing/OpencensusTracerFactory.java @@ -38,7 +38,7 @@ import io.opencensus.trace.Tracer; import io.opencensus.trace.Tracing; import java.util.Map; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; /** * A {@link ApiTracerFactory} to build instances of {@link OpencensusTracer}. @@ -50,8 +50,8 @@ */ @InternalApi("For google-cloud-java client use only") public final class OpencensusTracerFactory extends BaseApiTracerFactory { - @Nonnull private final Tracer internalTracer; - @Nonnull private final Map spanAttributes; + @NonNull private final Tracer internalTracer; + @NonNull private final Map spanAttributes; /** * Instantiates a new instance capturing the {@link io.opencensus.trace.Tracer} in {@code @@ -82,7 +82,7 @@ public OpencensusTracerFactory(Map spanAttributes) { * @param internalTracer the Opencensus tracer to wrap. */ @InternalApi("Visible for testing") - OpencensusTracerFactory(Tracer internalTracer, @Nonnull Map spanAttributes) { + OpencensusTracerFactory(Tracer internalTracer, @NonNull Map spanAttributes) { this.internalTracer = Preconditions.checkNotNull(internalTracer, "internalTracer can't be null"); ImmutableMap.Builder formattedSpanAttributes = ImmutableMap.builder(); diff --git a/gax-java/gax/src/main/java/com/google/api/gax/tracing/TraceFinisher.java b/gax-java/gax/src/main/java/com/google/api/gax/tracing/TraceFinisher.java index 292a827759..595b131023 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/tracing/TraceFinisher.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/tracing/TraceFinisher.java @@ -32,13 +32,13 @@ import com.google.api.core.ApiFutureCallback; import com.google.common.base.Preconditions; import java.util.concurrent.CancellationException; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; /** An {@link ApiFutureCallback} to mark a started operation trace as finished. */ class TraceFinisher implements ApiFutureCallback { private final ApiTracer tracer; - TraceFinisher(@Nonnull ApiTracer tracer) { + TraceFinisher(@NonNull ApiTracer tracer) { this.tracer = Preconditions.checkNotNull(tracer, "tracer can't be null"); } diff --git a/gax-java/gax/src/main/java/com/google/api/gax/tracing/TracedBidiCallable.java b/gax-java/gax/src/main/java/com/google/api/gax/tracing/TracedBidiCallable.java index fd2172752d..1ab46095bc 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/tracing/TracedBidiCallable.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/tracing/TracedBidiCallable.java @@ -40,7 +40,7 @@ import com.google.common.base.Preconditions; import java.util.concurrent.CancellationException; import java.util.concurrent.atomic.AtomicBoolean; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; /** * A wrapper callable that will wrap a callable chain in a trace. @@ -52,14 +52,14 @@ public class TracedBidiCallable extends BidiStreamingCallable { - @Nonnull private final ApiTracerFactory tracerFactory; - @Nonnull private final SpanName spanName; - @Nonnull private final BidiStreamingCallable innerCallable; + @NonNull private final ApiTracerFactory tracerFactory; + @NonNull private final SpanName spanName; + @NonNull private final BidiStreamingCallable innerCallable; public TracedBidiCallable( - @Nonnull BidiStreamingCallable innerCallable, - @Nonnull ApiTracerFactory tracerFactory, - @Nonnull SpanName spanName) { + @NonNull BidiStreamingCallable innerCallable, + @NonNull ApiTracerFactory tracerFactory, + @NonNull SpanName spanName) { this.tracerFactory = Preconditions.checkNotNull(tracerFactory, "tracerFactory can't be null"); this.spanName = Preconditions.checkNotNull(spanName, "spanName can't be null"); this.innerCallable = Preconditions.checkNotNull(innerCallable, "innerCallable can't be null"); diff --git a/gax-java/gax/src/main/java/com/google/api/gax/tracing/TracedClientStreamingCallable.java b/gax-java/gax/src/main/java/com/google/api/gax/tracing/TracedClientStreamingCallable.java index 773efe2dea..cb41c7ccf2 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/tracing/TracedClientStreamingCallable.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/tracing/TracedClientStreamingCallable.java @@ -38,7 +38,7 @@ import com.google.common.base.Preconditions; import java.util.concurrent.CancellationException; import java.util.concurrent.atomic.AtomicReference; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; /** * A wrapper callable that will wrap a callable chain in a trace. @@ -57,9 +57,9 @@ public class TracedClientStreamingCallable private final SpanName spanName; public TracedClientStreamingCallable( - @Nonnull ClientStreamingCallable innerCallable, - @Nonnull ApiTracerFactory tracerFactory, - @Nonnull SpanName spanName) { + @NonNull ClientStreamingCallable innerCallable, + @NonNull ApiTracerFactory tracerFactory, + @NonNull SpanName spanName) { this.tracerFactory = Preconditions.checkNotNull(tracerFactory, "tracerFactory can't be null"); this.spanName = Preconditions.checkNotNull(spanName, "spanName can't be null"); this.innerCallable = Preconditions.checkNotNull(innerCallable, "innerCallable can't be null"); @@ -98,9 +98,9 @@ private static class TracedRequestObserver implements ApiStreamObserve private final AtomicReference cancellationCauseHolder; TracedRequestObserver( - @Nonnull ApiTracer tracer, - @Nonnull ApiStreamObserver innerObserver, - @Nonnull AtomicReference cancellationCauseHolder) { + @NonNull ApiTracer tracer, + @NonNull ApiStreamObserver innerObserver, + @NonNull AtomicReference cancellationCauseHolder) { this.tracer = Preconditions.checkNotNull(tracer, "tracer can't be null"); this.innerObserver = Preconditions.checkNotNull(innerObserver, "innerObserver can't be null"); this.cancellationCauseHolder = @@ -137,14 +137,14 @@ public void onCompleted() { * close the current trace upon completion of the RPC. */ private static class TracedResponseObserver implements ApiStreamObserver { - @Nonnull private final ApiTracer tracer; - @Nonnull private final ApiStreamObserver innerObserver; - @Nonnull private final AtomicReference cancellationCauseHolder; + @NonNull private final ApiTracer tracer; + @NonNull private final ApiStreamObserver innerObserver; + @NonNull private final AtomicReference cancellationCauseHolder; TracedResponseObserver( - @Nonnull ApiTracer tracer, - @Nonnull ApiStreamObserver innerObserver, - @Nonnull AtomicReference cancellationCauseHolder) { + @NonNull ApiTracer tracer, + @NonNull ApiStreamObserver innerObserver, + @NonNull AtomicReference cancellationCauseHolder) { this.tracer = Preconditions.checkNotNull(tracer, "tracer can't be null"); this.innerObserver = Preconditions.checkNotNull(innerObserver, "innerObserver can't be null"); this.cancellationCauseHolder = cancellationCauseHolder; diff --git a/gax-java/gax/src/main/java/com/google/api/gax/tracing/TracedOperationCallable.java b/gax-java/gax/src/main/java/com/google/api/gax/tracing/TracedOperationCallable.java index 3b83d7fd75..e95135b048 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/tracing/TracedOperationCallable.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/tracing/TracedOperationCallable.java @@ -37,7 +37,7 @@ import com.google.api.gax.rpc.OperationCallable; import com.google.api.gax.tracing.ApiTracerFactory.OperationType; import com.google.common.util.concurrent.MoreExecutors; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; /** * This callable wraps a {@link OperationCallable} in a {@link ApiTracer}. @@ -48,14 +48,14 @@ public class TracedOperationCallable extends OperationCallable { - private @Nonnull OperationCallable innerCallable; - private @Nonnull ApiTracerFactory tracerFactory; - private @Nonnull SpanName spanName; + private @NonNull OperationCallable innerCallable; + private @NonNull ApiTracerFactory tracerFactory; + private @NonNull SpanName spanName; public TracedOperationCallable( - @Nonnull OperationCallable innerCallable, - @Nonnull ApiTracerFactory tracerFactory, - @Nonnull SpanName spanName) { + @NonNull OperationCallable innerCallable, + @NonNull ApiTracerFactory tracerFactory, + @NonNull SpanName spanName) { this.innerCallable = innerCallable; this.tracerFactory = tracerFactory; this.spanName = spanName; diff --git a/gax-java/gax/src/main/java/com/google/api/gax/tracing/TracedResponseObserver.java b/gax-java/gax/src/main/java/com/google/api/gax/tracing/TracedResponseObserver.java index ba72d2f5b7..bc6ab4d5b6 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/tracing/TracedResponseObserver.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/tracing/TracedResponseObserver.java @@ -34,7 +34,7 @@ import com.google.api.gax.rpc.StreamController; import com.google.common.base.Preconditions; import java.util.concurrent.atomic.AtomicBoolean; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; /** * A {@link ResponseObserver} to mark a started operation trace as finished. @@ -50,14 +50,14 @@ class TracedResponseObserver implements ResponseObserver { private AtomicBoolean wasCancelled; TracedResponseObserver( - @Nonnull ApiTracer tracer, @Nonnull ResponseObserver innerObserver) { + @NonNull ApiTracer tracer, @NonNull ResponseObserver innerObserver) { this(tracer, innerObserver, new AtomicBoolean()); } TracedResponseObserver( - @Nonnull ApiTracer tracer, - @Nonnull ResponseObserver innerObserver, - @Nonnull AtomicBoolean wasCancelled) { + @NonNull ApiTracer tracer, + @NonNull ResponseObserver innerObserver, + @NonNull AtomicBoolean wasCancelled) { this.tracer = Preconditions.checkNotNull(tracer, "tracer"); this.innerObserver = Preconditions.checkNotNull(innerObserver, "innerObserver"); this.wasCancelled = Preconditions.checkNotNull(wasCancelled, "wasCancelled"); diff --git a/gax-java/gax/src/main/java/com/google/api/gax/tracing/TracedServerStreamingCallable.java b/gax-java/gax/src/main/java/com/google/api/gax/tracing/TracedServerStreamingCallable.java index e46520e616..c136345456 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/tracing/TracedServerStreamingCallable.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/tracing/TracedServerStreamingCallable.java @@ -36,7 +36,7 @@ import com.google.api.gax.rpc.ServerStreamingCallable; import com.google.api.gax.tracing.ApiTracerFactory.OperationType; import com.google.common.base.Preconditions; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; /** * A wrapper callable that will wrap a callable chain in a trace. @@ -48,14 +48,14 @@ public final class TracedServerStreamingCallable extends ServerStreamingCallable { - @Nonnull private final ApiTracerFactory tracerFactory; - @Nonnull private final SpanName spanName; - @Nonnull private final ServerStreamingCallable innerCallable; + @NonNull private final ApiTracerFactory tracerFactory; + @NonNull private final SpanName spanName; + @NonNull private final ServerStreamingCallable innerCallable; public TracedServerStreamingCallable( - @Nonnull ServerStreamingCallable innerCallable, - @Nonnull ApiTracerFactory tracerFactory, - @Nonnull SpanName spanName) { + @NonNull ServerStreamingCallable innerCallable, + @NonNull ApiTracerFactory tracerFactory, + @NonNull SpanName spanName) { this.tracerFactory = Preconditions.checkNotNull(tracerFactory, "tracerFactory can't be null"); this.spanName = Preconditions.checkNotNull(spanName, "spanName can't be null"); this.innerCallable = Preconditions.checkNotNull(innerCallable, "innerCallable can't be null"); diff --git a/gax-java/gax/src/test/java/com/google/api/gax/rpc/testing/FakeCallContext.java b/gax-java/gax/src/test/java/com/google/api/gax/rpc/testing/FakeCallContext.java index 1cdefe435d..4f94f3d02f 100644 --- a/gax-java/gax/src/test/java/com/google/api/gax/rpc/testing/FakeCallContext.java +++ b/gax-java/gax/src/test/java/com/google/api/gax/rpc/testing/FakeCallContext.java @@ -50,8 +50,8 @@ import java.util.List; import java.util.Map; import java.util.Set; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; @InternalApi("for testing") public class FakeCallContext implements ApiCallContext { @@ -248,25 +248,23 @@ public java.time.Duration getTimeoutDuration() { @Override public ApiCallContext withStreamWaitTimeout( - @Nullable org.threeten.bp.Duration streamWaitTimeout) { + org.threeten.bp.@Nullable Duration streamWaitTimeout) { return withStreamWaitTimeoutDuration(toJavaTimeDuration(streamWaitTimeout)); } - @Nullable @Override - public java.time.Duration getStreamWaitTimeoutDuration() { + public java.time.@Nullable Duration getStreamWaitTimeoutDuration() { return streamWaitTimeout; } @Override public ApiCallContext withStreamIdleTimeout( - @Nullable org.threeten.bp.Duration streamIdleTimeout) { + org.threeten.bp.@Nullable Duration streamIdleTimeout) { return withStreamIdleTimeoutDuration(toJavaTimeDuration(streamIdleTimeout)); } - @Nullable @Override - public java.time.Duration getStreamIdleTimeoutDuration() { + public java.time.@Nullable Duration getStreamIdleTimeoutDuration() { return streamIdleTimeout; } @@ -315,7 +313,7 @@ public FakeCallContext withEndpointContext(EndpointContext endpointContext) { } @Override - public FakeCallContext withTimeout(@Nullable org.threeten.bp.Duration timeout) { + public FakeCallContext withTimeout(org.threeten.bp.@Nullable Duration timeout) { return withTimeoutDuration(toJavaTimeDuration(timeout)); } @@ -360,15 +358,14 @@ public FakeCallContext withTimeoutDuration(java.time.Duration timeout) { this.endpointContext); } - @Nullable @Override - public org.threeten.bp.Duration getTimeout() { + public org.threeten.bp.@Nullable Duration getTimeout() { return toThreetenDuration(getTimeoutDuration()); } @Override public ApiCallContext withStreamWaitTimeoutDuration( - @Nullable java.time.Duration streamWaitTimeout) { + java.time.@Nullable Duration streamWaitTimeout) { return new FakeCallContext( this.credentials, this.channel, @@ -383,15 +380,14 @@ public ApiCallContext withStreamWaitTimeoutDuration( this.endpointContext); } - @Nullable @Override - public org.threeten.bp.Duration getStreamWaitTimeout() { + public org.threeten.bp.@Nullable Duration getStreamWaitTimeout() { return toThreetenDuration(getStreamWaitTimeoutDuration()); } @Override public ApiCallContext withStreamIdleTimeoutDuration( - @Nullable java.time.Duration streamIdleTimeout) { + java.time.@Nullable Duration streamIdleTimeout) { Preconditions.checkNotNull(streamIdleTimeout); return new FakeCallContext( this.credentials, @@ -407,9 +403,8 @@ public ApiCallContext withStreamIdleTimeoutDuration( this.endpointContext); } - @Nullable @Override - public org.threeten.bp.Duration getStreamIdleTimeout() { + public org.threeten.bp.@Nullable Duration getStreamIdleTimeout() { return toThreetenDuration(getStreamIdleTimeoutDuration()); } @@ -463,7 +458,7 @@ public T getOption(Key key) { /** {@inheritDoc} */ @Override - @Nonnull + @NonNull public ApiTracer getTracer() { if (tracer == null) { return BaseApiTracer.getInstance(); @@ -473,7 +468,7 @@ public ApiTracer getTracer() { /** {@inheritDoc} */ @Override - public ApiCallContext withTracer(@Nonnull ApiTracer tracer) { + public ApiCallContext withTracer(@NonNull ApiTracer tracer) { Preconditions.checkNotNull(tracer); return new FakeCallContext( diff --git a/gax-java/gax/src/test/java/com/google/api/gax/rpc/testing/FakeOperationSnapshot.java b/gax-java/gax/src/test/java/com/google/api/gax/rpc/testing/FakeOperationSnapshot.java index 59db2a8008..c5a0dd33a4 100644 --- a/gax-java/gax/src/test/java/com/google/api/gax/rpc/testing/FakeOperationSnapshot.java +++ b/gax-java/gax/src/test/java/com/google/api/gax/rpc/testing/FakeOperationSnapshot.java @@ -33,7 +33,7 @@ import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.rpc.StatusCode; import com.google.auto.value.AutoValue; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; @InternalApi("for testing") @AutoValue diff --git a/gax-java/pom.xml b/gax-java/pom.xml index 2c8dcc34da..2061042ac6 100644 --- a/gax-java/pom.xml +++ b/gax-java/pom.xml @@ -65,9 +65,9 @@ ${threetenbp.version} - com.google.code.findbugs - jsr305 - 3.0.2 + org.jspecify + jspecify + 1.0.0 com.google.guava diff --git a/java-core/google-cloud-core-http/pom.xml b/java-core/google-cloud-core-http/pom.xml index 40e4804403..f352308bc7 100644 --- a/java-core/google-cloud-core-http/pom.xml +++ b/java-core/google-cloud-core-http/pom.xml @@ -55,8 +55,8 @@ gax-httpjson - com.google.code.findbugs - jsr305 + org.jspecify + jspecify io.opencensus diff --git a/java-core/google-cloud-core-http/src/main/java/com/google/cloud/http/CensusHttpModule.java b/java-core/google-cloud-core-http/src/main/java/com/google/cloud/http/CensusHttpModule.java index d141507cc0..59393478a9 100644 --- a/java-core/google-cloud-core-http/src/main/java/com/google/cloud/http/CensusHttpModule.java +++ b/java-core/google-cloud-core-http/src/main/java/com/google/cloud/http/CensusHttpModule.java @@ -28,7 +28,7 @@ import io.opencensus.trace.Tracer; import io.opencensus.trace.propagation.TextFormat; import java.io.IOException; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; /** * Provides utilities for Open Census to record http stats/trace information and propagate tracing @@ -46,7 +46,7 @@ public final class CensusHttpModule { @Nullable private final TextFormat propagationTextFormat; /** {@link TextFormat.Setter} for {@link #propagationTextFormat}. */ - @Nullable private final TextFormat.Setter propagationTextFormatSetter; + private final TextFormat.@Nullable Setter propagationTextFormatSetter; /** Whether spans are stored locally. */ private final boolean isRecordEvents; diff --git a/java-core/google-cloud-core/pom.xml b/java-core/google-cloud-core/pom.xml index b15e18e90c..91ed4d9665 100644 --- a/java-core/google-cloud-core/pom.xml +++ b/java-core/google-cloud-core/pom.xml @@ -96,8 +96,8 @@ test - com.google.code.findbugs - jsr305 + org.jspecify + jspecify com.google.truth diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/Binding.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/Binding.java index be16f87421..361b6f07eb 100644 --- a/java-core/google-cloud-core/src/main/java/com/google/cloud/Binding.java +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/Binding.java @@ -28,7 +28,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; /** * Class for Identity and Access Management (IAM) policies. IAM policies are used to specify access diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/Condition.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/Condition.java index c3c4c83fb9..908b1f1e79 100644 --- a/java-core/google-cloud-core/src/main/java/com/google/cloud/Condition.java +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/Condition.java @@ -18,7 +18,7 @@ import com.google.api.core.BetaApi; import com.google.auto.value.AutoValue; -import javax.annotation.Nullable; +import org.jspecify.annotations.Nullable; /** * Class for Identity and Access Management (IAM) policies. IAM policies are used to specify access diff --git a/java-shared-dependencies/third-party-dependencies/pom.xml b/java-shared-dependencies/third-party-dependencies/pom.xml index 49473690c6..e475d07c4b 100644 --- a/java-shared-dependencies/third-party-dependencies/pom.xml +++ b/java-shared-dependencies/third-party-dependencies/pom.xml @@ -27,6 +27,7 @@ 1.24 0.31.1 3.0.2 + 1.0.0 2.18.0 2.33.0 1.17.1 @@ -98,6 +99,11 @@ jsr305 ${findbugs.version} + + org.jspecify + jspecify + ${jspecify.version} + com.google.errorprone error_prone_annotations diff --git a/rules_java_gapic/java_gapic.bzl b/rules_java_gapic/java_gapic.bzl index fdab81e7af..a4fa0e2c97 100644 --- a/rules_java_gapic/java_gapic.bzl +++ b/rules_java_gapic/java_gapic.bzl @@ -294,7 +294,7 @@ def java_gapic_library( "@com_google_api_api_common//jar", "@com_google_api_gax_java//gax:gax", "@com_google_guava_guava//jar", - "@com_google_code_findbugs_jsr305//jar", + "@org_jspecify_jspecify//jar", "@org_threeten_threetenbp//jar", "@io_opencensus_opencensus_api//jar", "@com_google_auth_google_auth_library_credentials//jar",