Skip to content
Open
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
5 changes: 3 additions & 2 deletions api/src/main/java/io/grpc/Channel.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package io.grpc;

import javax.annotation.concurrent.ThreadSafe;

/**
* A virtual connection to a conceptual endpoint, to perform RPCs. A channel is free to have zero or
Expand All @@ -29,8 +28,10 @@
* implementations using {@link ClientInterceptor}. It is expected that most application
* code will not use this class directly but rather work with stubs that have been bound to a
* Channel that was decorated during application initialization.
*
* <p>This is thread-safe and should be considered
* for the errorprone ThreadSafe annotation in the future.
*/
@ThreadSafe
public abstract class Channel {
/**
* Create a {@link ClientCall} to the remote operation specified by the given
Expand Down
5 changes: 3 additions & 2 deletions api/src/main/java/io/grpc/ChannelLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@

package io.grpc;

import javax.annotation.concurrent.ThreadSafe;

/**
* A Channel-specific logger provided by GRPC library to {@link LoadBalancer} implementations.
* Information logged here goes to <strong>Channelz</strong>, and to the Java logger of this class
* as well.
*
* <p>This is thread-safe and should be considered
* for the errorprone ThreadSafe annotation in the future.
*/
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/5029")
@ThreadSafe
public abstract class ChannelLogger {
/**
* Log levels. See the table below for the mapping from the ChannelLogger levels to Channelz
Expand Down
5 changes: 3 additions & 2 deletions api/src/main/java/io/grpc/ClientInterceptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package io.grpc;

import javax.annotation.concurrent.ThreadSafe;

/**
* Interface for intercepting outgoing calls before they are dispatched by a {@link Channel}.
Expand All @@ -37,8 +36,10 @@
* without completing the previous ones first. Refer to the
* {@link io.grpc.ClientCall.Listener ClientCall.Listener} docs for more details regarding thread
* safety of the returned listener.
*
* <p>This is thread-safe and should be considered
* for the errorprone ThreadSafe annotation in the future.
*/
@ThreadSafe
public interface ClientInterceptor {
/**
* Intercept {@link ClientCall} creation by the {@code next} {@link Channel}.
Expand Down
5 changes: 3 additions & 2 deletions api/src/main/java/io/grpc/ClientStreamTracer.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
import static com.google.common.base.Preconditions.checkNotNull;

import com.google.common.base.MoreObjects;
import javax.annotation.concurrent.ThreadSafe;

/**
* {@link StreamTracer} for the client-side.
*
* <p>This is thread-safe and should be considered
* for the errorprone ThreadSafe annotation in the future.
*/
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/2861")
@ThreadSafe
public abstract class ClientStreamTracer extends StreamTracer {
/**
* Indicates how long the call was delayed, in nanoseconds, due to waiting for name resolution
Expand Down
5 changes: 3 additions & 2 deletions api/src/main/java/io/grpc/CompressorRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;

/**
* Encloses classes related to the compression and decompression of messages.
*
* <p>This is thread-safe and should be considered
* for the errorprone ThreadSafe annotation in the future.
*/
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1704")
@ThreadSafe
public final class CompressorRegistry {
private static final CompressorRegistry DEFAULT_INSTANCE = new CompressorRegistry(
new Codec.Gzip(),
Expand Down
5 changes: 3 additions & 2 deletions api/src/main/java/io/grpc/DecompressorRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@
import java.util.Map;
import java.util.Set;
import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;

/**
* Encloses classes related to the compression and decompression of messages.
*
* <p>This is thread-safe and should be considered
* for the errorprone ThreadSafe annotation in the future.
*/
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1704")
@ThreadSafe
public final class DecompressorRegistry {
static final Joiner ACCEPT_ENCODING_JOINER = Joiner.on(',');

Expand Down
5 changes: 3 additions & 2 deletions api/src/main/java/io/grpc/HandlerRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
import java.util.Collections;
import java.util.List;
import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;

/**
* Registry of services and their methods used by servers to dispatching incoming calls.
*
* <p>This is thread-safe and should be considered
* for the errorprone ThreadSafe annotation in the future.
*/
@ThreadSafe
public abstract class HandlerRegistry {

/**
Expand Down
13 changes: 9 additions & 4 deletions api/src/main/java/io/grpc/LoadBalancer.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;
import javax.annotation.concurrent.ThreadSafe;

/**
* A pluggable component that receives resolved addresses from {@link NameResolver} and provides the
Expand Down Expand Up @@ -447,10 +446,12 @@ public void requestConnection() {}
/**
* The main balancing logic. It <strong>must be thread-safe</strong>. Typically it should only
* synchronize on its own state, and avoid synchronizing with the LoadBalancer's state.
*
* <p>This is thread-safe and should be considered
* for the errorprone ThreadSafe annotation in the future.
*
* @since 1.2.0
*/
@ThreadSafe
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1771")
public abstract static class SubchannelPicker {
/**
Expand Down Expand Up @@ -1030,9 +1031,11 @@ public String toString() {
/**
* Provides essentials for LoadBalancer implementations.
*
* <p>This is thread-safe and should be considered
* for the errorprone ThreadSafe annotation in the future.
*
* @since 1.2.0
*/
@ThreadSafe
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1771")
public abstract static class Helper {
/**
Expand Down Expand Up @@ -1551,9 +1554,11 @@ public interface SubchannelStateListener {
/**
* Factory to create {@link LoadBalancer} instance.
*
* <p>This is thread-safe and should be considered
* for the errorprone ThreadSafe annotation in the future.
*
* @since 1.2.0
*/
@ThreadSafe
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1771")
public abstract static class Factory {
/**
Expand Down
7 changes: 4 additions & 3 deletions api/src/main/java/io/grpc/LoadBalancerRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,17 @@
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;

/**
* Registry of {@link LoadBalancerProvider}s. The {@link #getDefaultRegistry default instance}
* loads providers at runtime through the Java service provider mechanism.
*
*
* <p>This is thread-safe and should be considered
* for the errorprone ThreadSafe annotation in the future.
*
* @since 1.17.0
*/
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1771")
@ThreadSafe
public final class LoadBalancerRegistry {
private static final Logger logger = Logger.getLogger(LoadBalancerRegistry.class.getName());
private static LoadBalancerRegistry instance;
Expand Down
5 changes: 3 additions & 2 deletions api/src/main/java/io/grpc/ManagedChannel.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
package io.grpc;

import java.util.concurrent.TimeUnit;
import javax.annotation.concurrent.ThreadSafe;

/**
* A {@link Channel} that provides lifecycle management.
*
* <p>This is thread-safe and should be considered
* for the errorprone ThreadSafe annotation in the future.
*/
@ThreadSafe
public abstract class ManagedChannel extends Channel {
/**
* Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately
Expand Down
7 changes: 4 additions & 3 deletions api/src/main/java/io/grpc/ManagedChannelRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,17 @@
import java.util.ServiceLoader;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.concurrent.ThreadSafe;

/**
* Registry of {@link ManagedChannelProvider}s. The {@link #getDefaultRegistry default instance}
* loads providers at runtime through the Java service provider mechanism.
*
*
* <p>This is thread-safe and should be considered
* for the errorprone ThreadSafe annotation in the future.
*
* @since 1.32.0
*/
@Internal
@ThreadSafe
public final class ManagedChannelRegistry {
private static final Logger logger = Logger.getLogger(ManagedChannelRegistry.class.getName());
private static ManagedChannelRegistry instance;
Expand Down
7 changes: 4 additions & 3 deletions api/src/main/java/io/grpc/NameResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import java.util.concurrent.ScheduledExecutorService;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.ThreadSafe;

/**
* A pluggable component that resolves a target {@link URI} and return addresses to the caller.
Expand Down Expand Up @@ -214,11 +213,13 @@ public NameResolver newNameResolver(Uri targetUri, final Args args) {
* Receives address updates.
*
* <p>All methods are expected to return quickly.
*
*
* <p>This is thread-safe and should be considered
* for the errorprone ThreadSafe annotation in the future.
*
* @since 1.0.0
*/
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1770")
@ThreadSafe
public interface Listener {
/**
* Handles updates on resolved addresses and attributes.
Expand Down
7 changes: 4 additions & 3 deletions api/src/main/java/io/grpc/NameResolverRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,17 @@
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;

/**
* Registry of {@link NameResolverProvider}s. The {@link #getDefaultRegistry default instance}
* loads providers at runtime through the Java service provider mechanism.
*
*
* <p>This is thread-safe and should be considered
* for the errorprone ThreadSafe annotation in the future.
*
* @since 1.21.0
*/
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/4159")
@ThreadSafe
public final class NameResolverRegistry {
private static final Logger logger = Logger.getLogger(NameResolverRegistry.class.getName());
private static NameResolverRegistry instance;
Expand Down
5 changes: 3 additions & 2 deletions api/src/main/java/io/grpc/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.annotation.concurrent.ThreadSafe;

/**
* Server for listening for and dispatching incoming calls. It is not expected to be implemented by
* application code or interceptors.
*
* <p>This is thread-safe and should be considered
* for the errorprone ThreadSafe annotation in the future.
*/
@ThreadSafe
public abstract class Server {

/**
Expand Down
5 changes: 3 additions & 2 deletions api/src/main/java/io/grpc/ServerCallHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@

package io.grpc;

import javax.annotation.concurrent.ThreadSafe;

/**
* Interface to initiate processing of incoming remote calls. Advanced applications and generated
* code will implement this interface to allows {@link Server}s to invoke service methods.
*
* <p>This is thread-safe and should be considered
* for the errorprone ThreadSafe annotation in the future.
*/
@ThreadSafe
public interface ServerCallHandler<RequestT, ResponseT> {
/**
* Starts asynchronous processing of an incoming call.
Expand Down
5 changes: 3 additions & 2 deletions api/src/main/java/io/grpc/ServerInterceptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package io.grpc;

import javax.annotation.concurrent.ThreadSafe;

/**
* Interface for intercepting incoming calls before they are dispatched by
Expand All @@ -34,8 +33,10 @@
* without completing the previous ones first. Refer to the
* {@link io.grpc.ServerCall.Listener ServerCall.Listener} docs for more details regarding thread
* safety of the returned listener.
*
* <p>This is thread-safe and should be considered
* for the errorprone ThreadSafe annotation in the future.
*/
@ThreadSafe
public interface ServerInterceptor {
/**
* Intercept {@link ServerCall} dispatch by the {@code next} {@link ServerCallHandler}. General
Expand Down
5 changes: 3 additions & 2 deletions api/src/main/java/io/grpc/ServerRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@
import java.util.ServiceLoader;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.concurrent.ThreadSafe;

/**
* Registry of {@link ServerProvider}s. The {@link #getDefaultRegistry default instance} loads
* providers at runtime through the Java service provider mechanism.
*
* <p>This is thread-safe and should be considered
* for the errorprone ThreadSafe annotation in the future.
*/
@Internal
@ThreadSafe
public final class ServerRegistry {
private static final Logger logger = Logger.getLogger(ServerRegistry.class.getName());
private static ServerRegistry instance;
Expand Down
5 changes: 3 additions & 2 deletions api/src/main/java/io/grpc/ServerStreamTracer.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
package io.grpc;

import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;

/**
* Listens to events on a stream to collect metrics.
*
* <p>This is thread-safe and should be considered
* for the errorprone ThreadSafe annotation in the future.
*/
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/2861")
@ThreadSafe
public abstract class ServerStreamTracer extends StreamTracer {
/**
* Called before the interceptors and the call handlers and make changes to the Context object
Expand Down
5 changes: 3 additions & 2 deletions api/src/main/java/io/grpc/StreamTracer.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@

package io.grpc;

import javax.annotation.concurrent.ThreadSafe;

/**
* Listens to events on a stream to collect metrics.
*
* <p>DO NOT MOCK: Use TestStreamTracer. Mocks are not thread-safe
*
* <p>This is thread-safe and should be considered
* for the errorprone ThreadSafe annotation in the future.
*/
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/2861")
@ThreadSafe
public abstract class StreamTracer {
/**
* Stream is closed. This will be called exactly once.
Expand Down
Loading
Loading