Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions sdk-platform-java/gax-java/gax-grpc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,7 @@
<artifactId>grpc-googleapis</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<scope>provided</scope>
</dependency>
Comment thread
lqiu96 marked this conversation as resolved.

<dependency>
<groupId>org.graalvm.sdk</groupId>
<artifactId>nativeimage</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import javax.annotation.Nonnull;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

Expand Down Expand Up @@ -413,7 +412,7 @@
}

@Override
public RetrySettings getRetrySettings() {
public @Nullable RetrySettings getRetrySettings() {
return retrySettings;
}

Expand All @@ -436,7 +435,7 @@
}

@Override
public Set<StatusCode.Code> getRetryableCodes() {
public @Nullable Set<StatusCode.Code> getRetryableCodes() {

Check failure on line 438 in sdk-platform-java/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/GrpcCallContext.java

View check run for this annotation

SonarQubeCloud / [gapic-generator-java-root] SonarCloud Code Analysis

Fix the incompatibility of the annotation @Nullable to honor @NullMarked at class level of the overridden method.

See more on https://sonarcloud.io/project/issues?id=googleapis_google-cloud-java_showcase&issues=AZ_TLsbi-QtEJWT0PkOh&open=AZ_TLsbi-QtEJWT0PkOh&pullRequest=13959
return retryableCodes;
}

Expand Down Expand Up @@ -665,7 +664,6 @@

/** {@inheritDoc} */
@Override
@Nonnull
public ApiTracer getTracer() {
ApiTracer tracer = callOptions.getOption(TRACER_KEY);
if (tracer == null) {
Expand All @@ -676,7 +674,7 @@

/** {@inheritDoc} */
@Override
public GrpcCallContext withTracer(@Nonnull ApiTracer tracer) {
public GrpcCallContext withTracer(ApiTracer tracer) {
Preconditions.checkNotNull(tracer);
return withCallOptions(callOptions.withOption(TRACER_KEY, tracer));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
import com.google.longrunning.Operation;
import com.google.longrunning.stub.OperationsStub;
import io.grpc.MethodDescriptor;
import javax.annotation.Nonnull;
import org.jspecify.annotations.NullMarked;

/** Class with utility methods to create grpc-based direct callables. */
Expand Down Expand Up @@ -330,7 +329,7 @@ ClientStreamingCallable<RequestT, ResponseT> createClientStreamingCallable(
}

@VisibleForTesting
static ApiTracerContext getApiTracerContext(@Nonnull MethodDescriptor<?, ?> methodDescriptor) {
static ApiTracerContext getApiTracerContext(MethodDescriptor<?, ?> methodDescriptor) {
return ApiTracerContext.newBuilder()
.setFullMethodName(methodDescriptor.getFullMethodName())
.setTransport(ApiTracerContext.Transport.GRPC)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,8 @@ public boolean needsExecutor() {
return executor == null;
}

@Nullable
@Override
public Executor getExecutor() {
public @Nullable Executor getExecutor() {
return executor;
}

Expand Down Expand Up @@ -541,9 +540,9 @@ boolean canUseDirectPathWithUniverseDomain() {
return endpoint.contains(Credentials.GOOGLE_DEFAULT_UNIVERSE);
}

@Nullable
@VisibleForTesting
ChannelCredentials createMtlsChannelCredentials() throws IOException, GeneralSecurityException {
@Nullable ChannelCredentials createMtlsChannelCredentials()
throws IOException, GeneralSecurityException {
if (mtlsProvider == null) {
return null;
}
Expand Down Expand Up @@ -609,9 +608,8 @@ ChannelCredentials createMtlsChannelCredentials() throws IOException, GeneralSec
* @return {@link ChannelCredentials} to use to create an mtls connection between client and S2A
* @throws IOException on error
*/
@Nullable
@VisibleForTesting
ChannelCredentials createMtlsToS2AChannelCredentials(
@Nullable ChannelCredentials createMtlsToS2AChannelCredentials(
File trustBundle, File privateKey, File certChain) throws IOException {
if (trustBundle == null || privateKey == null || certChain == null) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@
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.Nullable;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;

Expand All @@ -68,21 +67,19 @@ void testRetryNoRaceCondition() throws Exception {
ManagedChannelBuilder.forAddress("localhost", 1234).usePlaintext().build();
StreamResumptionStrategy<Color, Money> resumptionStrategy =
new StreamResumptionStrategy<Color, Money>() {
@Nonnull

@Override
public StreamResumptionStrategy<Color, Money> createNew() {
return this;
}

@Nonnull
@Override
public Money processResponse(Money response) {
return response;
}

@Nullable
@Override
public Color getResumeRequest(Color originalRequest) {
public @Nullable Color getResumeRequest(Color originalRequest) {
return originalRequest;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
import java.util.logging.Level;
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;
Expand Down Expand Up @@ -560,8 +560,7 @@ void testWithDefaultDirectPathServiceConfig() {
assertThat(lbConfig.keySet()).containsExactly("pick_first");
}

@Nullable
private static Map<String, ?> getAsObject(Map<String, ?> json, String key) {
private static @Nullable Map<String, ?> getAsObject(Map<String, ?> json, String key) {
Object mapObject = json.get(key);
if (mapObject == null) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<RequestT, ResponseT> extends ClientCall<RequestT, ResponseT> {

Expand Down
6 changes: 1 addition & 5 deletions sdk-platform-java/gax-java/gax-httpjson/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,7 @@
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java-util</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.google.auto.value</groupId>
<artifactId>auto-value-annotations</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import javax.annotation.Nonnull;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

Expand Down Expand Up @@ -510,7 +509,7 @@
}

@Override
public RetrySettings getRetrySettings() {
public @Nullable RetrySettings getRetrySettings() {
return retrySettings;
}

Expand All @@ -531,7 +530,7 @@
}

@Override
public Set<StatusCode.Code> getRetryableCodes() {
public @Nullable Set<StatusCode.Code> getRetryableCodes() {

Check failure on line 533 in sdk-platform-java/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonCallContext.java

View check run for this annotation

SonarQubeCloud / [gapic-generator-java-root] SonarCloud Code Analysis

Fix the incompatibility of the annotation @Nullable to honor @NullMarked at class level of the overridden method.

See more on https://sonarcloud.io/project/issues?id=googleapis_google-cloud-java_showcase&issues=AZ_TLsYv-QtEJWT0PkOg&open=AZ_TLsYv-QtEJWT0PkOg&pullRequest=13959
return retryableCodes;
}

Expand Down Expand Up @@ -588,7 +587,6 @@
return withCallOptions(builder.setDeadline(newDeadline).build());
}

@Nonnull
@Override
public ApiTracer getTracer() {
if (tracer == null) {
Expand All @@ -599,7 +597,7 @@

/** {@inheritDoc} */
@Override
public HttpJsonCallContext withTracer(@Nonnull ApiTracer newTracer) {
public HttpJsonCallContext withTracer(ApiTracer newTracer) {
Preconditions.checkNotNull(newTracer);
HttpJsonCallOptions newCallOptions = callOptions.toBuilder().setTracer(newTracer).build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import com.google.api.gax.rpc.UnaryCallable;
import com.google.api.gax.tracing.ApiTracerContext;
import com.google.api.gax.tracing.TracedUnaryCallable;
import javax.annotation.Nonnull;
import org.jspecify.annotations.NullMarked;

/** Class with utility methods to create http/json-based direct callables. */
Expand Down Expand Up @@ -222,7 +221,7 @@ ServerStreamingCallable<RequestT, ResponseT> createServerStreamingCallable(
return callable.withDefaultCallContext(clientContext.getDefaultCallContext());
}

static ApiTracerContext getApiTracerContext(@Nonnull ApiMethodDescriptor<?, ?> methodDescriptor) {
static ApiTracerContext getApiTracerContext(ApiMethodDescriptor<?, ?> methodDescriptor) {
return ApiTracerContext.newBuilder()
.setFullMethodName(methodDescriptor.getFullMethodName())
.setHttpMethod(methodDescriptor.getHttpMethod())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,11 @@ interface ResultListener {

@AutoValue
abstract static class RunnableResult {
@Nullable
abstract HttpJsonMetadata getResponseHeaders();
abstract @Nullable HttpJsonMetadata getResponseHeaders();

abstract int getStatusCode();

@Nullable
abstract InputStream getResponseContent();
abstract @Nullable InputStream getResponseContent();

abstract HttpJsonMetadata getTrailers();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,8 @@ public boolean needsExecutor() {
return executor == null;
}

@Nullable
@Override
public Executor getExecutor() {
public @Nullable Executor getExecutor() {
return executor;
}

Expand Down
6 changes: 1 addition & 5 deletions sdk-platform-java/gax-java/gax/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,7 @@
<groupId>com.google.auth</groupId>
<artifactId>google-auth-library-oauth2-http</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<scope>provided</scope>
</dependency>
Comment thread
nnicolee marked this conversation as resolved.

<dependency>
<groupId>org.graalvm.sdk</groupId>
<artifactId>nativeimage</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Nonnull;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

Expand Down Expand Up @@ -98,10 +97,10 @@
private final Object flushLock = new Object();
private final Object elementLock = new Object();
private final Future<?> scheduledFuture;
private SettableApiFuture<Void> closeFuture;
private @Nullable SettableApiFuture<Void> closeFuture;
private final BatcherStats batcherStats = new BatcherStats();
private final FlowController flowController;
private final ApiCallContext callContext;
private final @Nullable ApiCallContext callContext;

// If element threshold or bytes threshold is 0, it means that it'll always flush every element
// without batching
Expand Down Expand Up @@ -479,7 +478,7 @@
private long totalThrottledTimeMs = 0;
private BatchResource resource;

private volatile ApiFuture<ResponseT> responseFuture;
private volatile @Nullable ApiFuture<ResponseT> responseFuture;

Check warning on line 481 in sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/batching/BatcherImpl.java

View check run for this annotation

SonarQubeCloud / [gapic-generator-java-root] SonarCloud Code Analysis

Use a thread-safe type; adding "volatile" is not enough to make this field thread-safe.

See more on https://sonarcloud.io/project/issues?id=googleapis_google-cloud-java_showcase&issues=AZ_TLsU9-QtEJWT0PkOf&open=AZ_TLsU9-QtEJWT0PkOf&pullRequest=13959

private Batch(
RequestT prototype,
Expand All @@ -503,7 +502,7 @@
totalThrottledTimeMs += throttledTimeMs;
}

void setResponseFuture(@Nonnull ApiFuture<ResponseT> responseFuture) {
void setResponseFuture(ApiFuture<ResponseT> responseFuture) {
Preconditions.checkNotNull(responseFuture);
this.responseFuture = responseFuture;
}
Expand Down Expand Up @@ -562,7 +561,7 @@
static class PushCurrentBatchRunnable<ElementT, ElementResultT, RequestT, ResponseT>
implements Runnable {

private Future<?> scheduledFuture;
private @Nullable Future<?> scheduledFuture;
private final WeakReference<BatcherImpl<ElementT, ElementResultT, RequestT, ResponseT>>
batcherReferent;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ synchronized <T extends BatchEntry> void recordBatchElementsCompletion(
}

/** Calculates and formats the message with request and entry failure count. */
@Nullable
synchronized BatchingException asException() {
synchronized @Nullable BatchingException asException() {
if (requestExceptionCounts.isEmpty() && requestPartialFailureCount == 0) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@
package com.google.api.gax.batching;

import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

/** Represents exception occurred during batching. */
@NullMarked
public final class BatchingException extends RuntimeException {

BatchingException(String message) {
BatchingException(@Nullable String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ public abstract class GoogleCredentialsProvider implements CredentialsProvider {
public abstract boolean getUseJwtAccessWithScope();

@VisibleForTesting
@Nullable
abstract GoogleCredentials getOAuth2Credentials();
abstract @Nullable GoogleCredentials getOAuth2Credentials();

@Override
public Credentials getCredentials() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
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.NullMarked;
import org.jspecify.annotations.Nullable;

/**
* Backwards compatibility class to aid in transition to adding operation state to {@link
Expand All @@ -50,19 +50,18 @@
}

/** {@inheritDoc} */
@Nonnull
@Override
public ApiTracer getTracer() {
return BaseApiTracer.getInstance();
}

@Override
public RetrySettings getRetrySettings() {
public @Nullable RetrySettings getRetrySettings() {
return null;
}

@Override
public Set<Code> getRetryableCodes() {
public @Nullable Set<Code> getRetryableCodes() {

Check failure on line 64 in sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/retrying/NoopRetryingContext.java

View check run for this annotation

SonarQubeCloud / [gapic-generator-java-root] SonarCloud Code Analysis

Fix the incompatibility of the annotation @Nullable to honor @NullMarked at class level of the overridden method.

See more on https://sonarcloud.io/project/issues?id=googleapis_google-cloud-java_showcase&issues=AZ_TLsT_-QtEJWT0PkOe&open=AZ_TLsT_-QtEJWT0PkOe&pullRequest=13959
return null;
}
}
Loading
Loading