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 0cc76f3eea..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,7 +20,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; @AutoValue @@ -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/writer/ImportWriterVisitor.java b/gapic-generator-java/src/main/java/com/google/api/generator/engine/writer/ImportWriterVisitor.java index d6e6a0320c..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,7 +69,7 @@ import java.util.Set; import java.util.TreeSet; import java.util.stream.Collectors; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; public class ImportWriterVisitor implements AstNodeVisitor { @@ -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/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/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/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 246c76405b..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,7 +64,7 @@ import java.util.Map; import java.util.Objects; import java.util.Set; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; /** @@ -626,7 +626,7 @@ public GrpcCallContext withRequestParamsDynamicHeaderOption(String requestParams /** {@inheritDoc} */ @Override - @Nonnull + @NonNull public ApiTracer getTracer() { ApiTracer tracer = callOptions.getOption(TRACER_KEY); if (tracer == null) { @@ -637,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/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 5f7bdf8819..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,7 +52,7 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; -import javax.annotation.Nonnull; +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-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 ad0164fed0..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,7 +55,7 @@ import java.util.Map; import java.util.Objects; import java.util.Set; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; /** @@ -587,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) { @@ -598,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/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/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 a69ab7c411..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,7 +64,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; import org.jspecify.annotations.Nullable; /** @@ -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/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 4a745f0a7c..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,7 +33,7 @@ import com.google.api.gax.rpc.StatusCode; import com.google.api.gax.tracing.ApiTracer; import java.util.Set; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; /** @@ -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 3178a866c9..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,7 +29,7 @@ */ package com.google.api.gax.retrying; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; /** @@ -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 fb14424d65..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,7 +41,7 @@ import java.util.List; import java.util.Map; import java.util.Set; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; /** @@ -173,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(); /** @@ -185,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 a5058e019f..2e9d8b6d90 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 @@ -58,7 +58,7 @@ import java.util.Set; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; /** @@ -101,14 +101,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(); @@ -124,7 +122,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 78ac3f803d..5253780ad2 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,7 +39,7 @@ import com.google.common.base.MoreObjects; import java.io.IOException; import java.util.concurrent.Executor; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; /** @@ -113,14 +113,12 @@ public final WatchdogProvider getWatchdogProvider() { } /** 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(); } 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 74484ef50a..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,7 +34,7 @@ import com.google.api.core.ObsoleteApi; import java.time.Duration; import java.util.concurrent.ScheduledExecutorService; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; /** @@ -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 725c2a02e8..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,7 +36,7 @@ import com.google.api.core.ObsoleteApi; import com.google.common.base.Preconditions; import java.util.concurrent.ScheduledExecutorService; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; /** @@ -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 0342bea45d..60240abefc 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,7 +51,7 @@ import com.google.common.base.Preconditions; import java.io.IOException; import java.util.concurrent.Executor; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; /** @@ -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; /** * Indicate when creating transport whether it is allowed to use mTLS endpoint instead of the @@ -207,14 +207,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; } @@ -223,7 +221,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; } @@ -272,8 +270,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; @@ -536,7 +534,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)); } @@ -544,7 +542,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(); @@ -568,7 +566,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(); @@ -646,13 +644,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/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 2eab2e1465..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,7 +50,7 @@ import java.util.List; import java.util.Map; import java.util.Set; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; @InternalApi("for testing") @@ -458,7 +458,7 @@ public T getOption(Key key) { /** {@inheritDoc} */ @Override - @Nonnull + @NonNull public ApiTracer getTracer() { if (tracer == null) { return BaseApiTracer.getInstance(); @@ -468,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(