Skip to content

Commit 921f88a

Browse files
authoredNov 12, 2024··
services: Deprecate V1alpha (#11681)
1 parent 8237ae2 commit 921f88a

File tree

11 files changed

+27
-19
lines changed

11 files changed

+27
-19
lines changed
 

Diff for: ‎documentation/server-reflection-tutorial.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ proto-based services.
1010
## Enable Server Reflection
1111

1212
gRPC-Java Server Reflection is implemented by
13-
`io.grpc.protobuf.services.ProtoReflectionService` in the `grpc-services`
13+
`io.grpc.protobuf.services.ProtoReflectionServiceV1` in the `grpc-services`
1414
package. To enable server reflection, you need to add the
15-
`ProtoReflectionService` to your gRPC server.
15+
`ProtoReflectionServiceV1` to your gRPC server.
1616

1717
For example, to enable server reflection in
1818
`examples/src/main/java/io/grpc/examples/helloworld/HelloWorldServer.java`, we
@@ -35,15 +35,15 @@ need to make the following changes:
3535

3636
import io.grpc.Server;
3737
import io.grpc.ServerBuilder;
38-
+import io.grpc.protobuf.services.ProtoReflectionService;
38+
+import io.grpc.protobuf.services.ProtoReflectionServiceV1;
3939
import io.grpc.stub.StreamObserver;
4040
import java.io.IOException;
4141
import java.util.logging.Logger;
4242
@@ -50,6 +51,7 @@ public class HelloWorldServer {
4343
int port = 50051;
4444
server = ServerBuilder.forPort(port)
4545
.addService(new GreeterImpl())
46-
+ .addService(ProtoReflectionService.newInstance())
46+
+ .addService(ProtoReflectionServiceV1.newInstance())
4747
.build()
4848
.start();
4949
logger.info("Server started, listening on " + port);

Diff for: ‎examples/example-debug/src/main/java/io/grpc/examples/debug/HelloWorldDebuggableClient.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import io.grpc.examples.helloworld.GreeterGrpc;
2828
import io.grpc.examples.helloworld.HelloReply;
2929
import io.grpc.examples.helloworld.HelloRequest;
30-
import io.grpc.protobuf.services.ProtoReflectionService;
30+
import io.grpc.protobuf.services.ProtoReflectionServiceV1;
3131
import io.grpc.services.AdminInterface;
3232
import java.util.concurrent.TimeUnit;
3333
import java.util.logging.Level;

Diff for: ‎examples/example-debug/src/main/java/io/grpc/examples/debug/HostnameDebuggableServer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import io.grpc.Server;
2222
import io.grpc.ServerBuilder;
2323
import io.grpc.health.v1.HealthCheckResponse.ServingStatus;
24-
import io.grpc.protobuf.services.ProtoReflectionService;
24+
import io.grpc.protobuf.services.ProtoReflectionServiceV1;
2525
import io.grpc.services.AdminInterface;
2626
import io.grpc.services.HealthStatusManager;
2727
import java.io.IOException;

Diff for: ‎examples/example-hostname/src/main/java/io/grpc/examples/hostname/HostnameServer.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import io.grpc.Server;
2222
import io.grpc.ServerBuilder;
2323
import io.grpc.health.v1.HealthCheckResponse.ServingStatus;
24-
import io.grpc.protobuf.services.ProtoReflectionService;
24+
import io.grpc.protobuf.services.ProtoReflectionServiceV1;
2525
import io.grpc.services.HealthStatusManager;
2626
import java.io.IOException;
2727
import java.util.concurrent.TimeUnit;
@@ -53,7 +53,7 @@ public static void main(String[] args) throws IOException, InterruptedException
5353
HealthStatusManager health = new HealthStatusManager();
5454
final Server server = Grpc.newServerBuilderForPort(port, InsecureServerCredentials.create())
5555
.addService(new HostnameGreeter(hostname))
56-
.addService(ProtoReflectionService.newInstance())
56+
.addService(ProtoReflectionServiceV1.newInstance())
5757
.addService(health.getHealthService())
5858
.build()
5959
.start();

Diff for: ‎examples/example-reflection/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
gRPC Reflection Example
22
================
33

4-
The reflection example has a Hello World server with `ProtoReflectionService` registered.
4+
The reflection example has a Hello World server with `ProtoReflectionServiceV1` registered.
55

66
### Build the example
77

Diff for: ‎examples/example-reflection/src/main/java/io/grpc/examples/reflection/ReflectionServer.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import io.grpc.examples.helloworld.GreeterGrpc;
88
import io.grpc.examples.helloworld.HelloReply;
99
import io.grpc.examples.helloworld.HelloRequest;
10-
import io.grpc.protobuf.services.ProtoReflectionService;
10+
import io.grpc.protobuf.services.ProtoReflectionServiceV1;
1111
import io.grpc.stub.StreamObserver;
1212
import java.io.IOException;
1313
import java.util.concurrent.TimeUnit;
@@ -26,7 +26,7 @@ private void start() throws IOException {
2626
int port = 50051;
2727
server = Grpc.newServerBuilderForPort(port, InsecureServerCredentials.create())
2828
.addService(new GreeterImpl())
29-
.addService(ProtoReflectionService.newInstance()) // add reflection service
29+
.addService(ProtoReflectionServiceV1.newInstance()) // add reflection service
3030
.build()
3131
.start();
3232
logger.info("Server started, listening on " + port);

Diff for: ‎examples/example-xds/src/main/java/io/grpc/examples/helloworldxds/XdsHelloWorldServer.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import io.grpc.Server;
2121
import io.grpc.ServerCredentials;
2222
import io.grpc.health.v1.HealthCheckResponse.ServingStatus;
23-
import io.grpc.protobuf.services.ProtoReflectionService;
23+
import io.grpc.protobuf.services.ProtoReflectionServiceV1;
2424
import io.grpc.services.HealthStatusManager;
2525
import io.grpc.xds.XdsServerBuilder;
2626
import io.grpc.xds.XdsServerCredentials;
@@ -66,7 +66,7 @@ public static void main(String[] args) throws IOException, InterruptedException
6666
final HealthStatusManager health = new HealthStatusManager();
6767
final Server server = XdsServerBuilder.forPort(port, credentials)
6868
.addService(new HostnameGreeter(hostname))
69-
.addService(ProtoReflectionService.newInstance()) // convenient for command line tools
69+
.addService(ProtoReflectionServiceV1.newInstance()) // convenient for command line tools
7070
.addService(health.getHealthService()) // allow management servers to monitor health
7171
.build()
7272
.start();

Diff for: ‎interop-testing/src/main/java/io/grpc/testing/integration/XdsTestClient.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.google.common.util.concurrent.MoreExecutors;
2929
import com.google.common.util.concurrent.SettableFuture;
3030
import com.google.protobuf.ByteString;
31+
import io.grpc.BindableService;
3132
import io.grpc.CallOptions;
3233
import io.grpc.Channel;
3334
import io.grpc.ClientCall;
@@ -273,11 +274,13 @@ private void run() {
273274
.build();
274275
csmObservability.registerGlobal();
275276
}
277+
@SuppressWarnings("deprecation")
278+
BindableService oldReflectionService = ProtoReflectionService.newInstance();
276279
statsServer =
277280
Grpc.newServerBuilderForPort(statsPort, InsecureServerCredentials.create())
278281
.addService(new XdsStatsImpl())
279282
.addService(new ConfigureUpdateServiceImpl())
280-
.addService(ProtoReflectionService.newInstance())
283+
.addService(oldReflectionService)
281284
.addService(ProtoReflectionServiceV1.newInstance())
282285
.addServices(AdminInterface.getStandardServices())
283286
.build();

Diff for: ‎interop-testing/src/main/java/io/grpc/testing/integration/XdsTestServer.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.google.common.collect.ImmutableMap;
2121
import com.google.common.collect.Iterables;
2222
import com.google.protobuf.ByteString;
23+
import io.grpc.BindableService;
2324
import io.grpc.ForwardingServerCall.SimpleForwardingServerCall;
2425
import io.grpc.Grpc;
2526
import io.grpc.InsecureServerCredentials;
@@ -212,6 +213,8 @@ void start() throws Exception {
212213
throw new RuntimeException(e);
213214
}
214215
health = new HealthStatusManager();
216+
@SuppressWarnings("deprecation")
217+
BindableService oldReflectionService = ProtoReflectionService.newInstance();
215218
if (secureMode) {
216219
if (addressType != Util.AddressType.IPV4_IPV6) {
217220
throw new IllegalArgumentException("Secure mode only supports IPV4_IPV6 address type");
@@ -220,7 +223,7 @@ void start() throws Exception {
220223
Grpc.newServerBuilderForPort(maintenancePort, InsecureServerCredentials.create())
221224
.addService(new XdsUpdateHealthServiceImpl(health))
222225
.addService(health.getHealthService())
223-
.addService(ProtoReflectionService.newInstance())
226+
.addService(oldReflectionService)
224227
.addService(ProtoReflectionServiceV1.newInstance())
225228
.addServices(AdminInterface.getStandardServices())
226229
.build();
@@ -272,7 +275,7 @@ void start() throws Exception {
272275
new TestServiceImpl(serverId, host), new TestInfoInterceptor(host)))
273276
.addService(new XdsUpdateHealthServiceImpl(health))
274277
.addService(health.getHealthService())
275-
.addService(ProtoReflectionService.newInstance())
278+
.addService(oldReflectionService)
276279
.addService(ProtoReflectionServiceV1.newInstance())
277280
.addServices(AdminInterface.getStandardServices())
278281
.build();

Diff for: ‎services/src/main/java/io/grpc/protobuf/services/ProtoReflectionService.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,25 @@
2828

2929
/**
3030
* Provides a reflection service for Protobuf services (including the reflection service itself).
31-
* Uses the deprecated v1alpha proto. New users should use ProtoReflectionServiceV1 instead.
3231
*
3332
* <p>Separately tracks mutable and immutable services. Throws an exception if either group of
3433
* services contains multiple Protobuf files with declarations of the same service, method, type, or
3534
* extension.
35+
* Uses the deprecated v1alpha proto. New users should use {@link ProtoReflectionServiceV1} instead.
3636
*/
3737
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/2222")
3838
public final class ProtoReflectionService implements BindableService {
3939

4040
private ProtoReflectionService() {
4141
}
4242

43+
@Deprecated
4344
public static BindableService newInstance() {
4445
return new ProtoReflectionService();
4546
}
4647

4748
@Override
49+
@SuppressWarnings("deprecation")
4850
public ServerServiceDefinition bindService() {
4951
ServerServiceDefinition serverServiceDefinitionV1 = ProtoReflectionServiceV1.newInstance()
5052
.bindService();

Diff for: ‎services/src/test/java/io/grpc/protobuf/services/ProtoReflectionServiceTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ public class ProtoReflectionServiceTest {
7171

7272
private static final String TEST_HOST = "localhost";
7373
private MutableHandlerRegistry handlerRegistry = new MutableHandlerRegistry();
74-
private BindableService reflectionService;
74+
@SuppressWarnings("deprecation")
75+
private BindableService reflectionService = ProtoReflectionService.newInstance();
7576
private ServerServiceDefinition dynamicService =
7677
new DynamicServiceGrpc.DynamicServiceImplBase() {}.bindService();
7778
private ServerServiceDefinition anotherDynamicService =
@@ -80,7 +81,6 @@ public class ProtoReflectionServiceTest {
8081

8182
@Before
8283
public void setUp() throws Exception {
83-
reflectionService = ProtoReflectionService.newInstance();
8484
Server server =
8585
InProcessServerBuilder.forName("proto-reflection-test")
8686
.directExecutor()

0 commit comments

Comments
 (0)
Please sign in to comment.