Skip to content

Commit abffc76

Browse files
committed
addressing reviewer comments
1 parent aff1cac commit abffc76

File tree

14 files changed

+42
-481
lines changed

14 files changed

+42
-481
lines changed

benchmarks/src/generated/main/grpc/io/grpc/benchmarks/proto/BenchmarkServiceGrpc.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ public io.grpc.stub.StreamObserver<Req> invoke(
262262
}
263263
}
264264

265-
public static final class BenchmarkServiceDescriptorWrapper implements io.grpc.protobuf.reflection.ProtoFileDescriptorWrapper {
265+
private static final class BenchmarkServiceDescriptorSupplier implements io.grpc.protobuf.ProtoFileDescriptorSupplier {
266266
@java.lang.Override
267267
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
268268
return io.grpc.benchmarks.proto.Services.getDescriptor();
@@ -274,7 +274,7 @@ public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
274274
public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() {
275275
if (serviceDescriptor == null) {
276276
serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME,
277-
new BenchmarkServiceDescriptorWrapper(),
277+
new BenchmarkServiceDescriptorSupplier(),
278278
METHOD_UNARY_CALL,
279279
METHOD_STREAMING_CALL);
280280
}

benchmarks/src/generated/main/grpc/io/grpc/benchmarks/proto/WorkerServiceGrpc.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ public io.grpc.stub.StreamObserver<Req> invoke(
380380
}
381381
}
382382

383-
public static final class WorkerServiceDescriptorWrapper implements io.grpc.protobuf.reflection.ProtoFileDescriptorWrapper {
383+
private static final class WorkerServiceDescriptorSupplier implements io.grpc.protobuf.ProtoFileDescriptorSupplier {
384384
@java.lang.Override
385385
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
386386
return io.grpc.benchmarks.proto.Services.getDescriptor();
@@ -392,7 +392,7 @@ public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
392392
public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() {
393393
if (serviceDescriptor == null) {
394394
serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME,
395-
new WorkerServiceDescriptorWrapper(),
395+
new WorkerServiceDescriptorSupplier(),
396396
METHOD_RUN_SERVER,
397397
METHOD_RUN_CLIENT,
398398
METHOD_CORE_COUNT,

compiler/src/java_plugin/cpp/java_generator.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -889,11 +889,11 @@ static void PrintGetServiceDescriptorMethod(const ServiceDescriptor* service,
889889

890890

891891
if (flavor == ProtoFlavor::NORMAL) {
892-
(*vars)["proto_descriptor_wrapper"] = service->name() + "DescriptorWrapper";
892+
(*vars)["proto_descriptor_supplier"] = service->name() + "DescriptorSupplier";
893893
(*vars)["proto_class_name"] = google::protobuf::compiler::java::ClassName(service->file());
894894
p->Print(
895895
*vars,
896-
"public static final class $proto_descriptor_wrapper$ implements $ProtoFileDescriptorWrapper$ {\n");
896+
"private static final class $proto_descriptor_supplier$ implements $ProtoFileDescriptorSupplier$ {\n");
897897
p->Indent();
898898
p->Print(*vars, "@$Override$\n");
899899
p->Print(
@@ -923,7 +923,7 @@ static void PrintGetServiceDescriptorMethod(const ServiceDescriptor* service,
923923
p->Indent();
924924
p->Print(
925925
*vars,
926-
"new $proto_descriptor_wrapper$()");
926+
"new $proto_descriptor_supplier$()");
927927
p->Outdent();
928928
p->Outdent();
929929
} else {
@@ -1180,8 +1180,8 @@ void GenerateService(const ServiceDescriptor* service,
11801180
"io.grpc.ServerServiceDefinition";
11811181
vars["ServiceDescriptor"] =
11821182
"io.grpc.ServiceDescriptor";
1183-
vars["ProtoFileDescriptorWrapper"] =
1184-
"io.grpc.protobuf.reflection.ProtoFileDescriptorWrapper";
1183+
vars["ProtoFileDescriptorSupplier"] =
1184+
"io.grpc.protobuf.ProtoFileDescriptorSupplier";
11851185
vars["AbstractStub"] = "io.grpc.stub.AbstractStub";
11861186
vars["MethodDescriptor"] = "io.grpc.MethodDescriptor";
11871187
vars["NanoUtils"] = "io.grpc.protobuf.nano.NanoUtils";

compiler/src/test/golden/TestService.java.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ public class TestServiceGrpc {
425425
}
426426
}
427427

428-
public static final class TestServiceDescriptorWrapper implements io.grpc.protobuf.reflection.ProtoFileDescriptorWrapper {
428+
private static final class TestServiceDescriptorSupplier implements io.grpc.protobuf.ProtoFileDescriptorSupplier {
429429
@java.lang.Override
430430
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
431431
return io.grpc.testing.integration.Test.getDescriptor();
@@ -437,7 +437,7 @@ public class TestServiceGrpc {
437437
public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() {
438438
if (serviceDescriptor == null) {
439439
serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME,
440-
new TestServiceDescriptorWrapper(),
440+
new TestServiceDescriptorSupplier(),
441441
METHOD_UNARY_CALL,
442442
METHOD_STREAMING_OUTPUT_CALL,
443443
METHOD_STREAMING_INPUT_CALL,

core/src/main/java/io/grpc/ServiceDescriptor.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,27 @@ public final class ServiceDescriptor {
4747

4848
private final String name;
4949
private final Collection<MethodDescriptor<?, ?>> methods;
50-
private Object attachedObject = null;
50+
private final Object marshallerDescriptor;
5151

5252
public ServiceDescriptor(String name, MethodDescriptor<?, ?>... methods) {
53-
this(name, Arrays.asList(methods));
53+
this(name, null, Arrays.asList(methods));
5454
}
5555

5656
public ServiceDescriptor(String name, Collection<MethodDescriptor<?, ?>> methods) {
57-
this.name = Preconditions.checkNotNull(name, "name");
58-
this.methods = Collections.unmodifiableList(new ArrayList<MethodDescriptor<?, ?>>(methods));
57+
this(name, null, methods);
5958
}
6059

61-
public ServiceDescriptor(String name, Object attachedObject, MethodDescriptor<?, ?>... methods) {
62-
this(name, methods);
63-
this.attachedObject = attachedObject;
60+
public ServiceDescriptor(String name, Object marshallerDescriptor,
61+
MethodDescriptor<?, ?>... methods) {
62+
this(name, marshallerDescriptor, Arrays.asList(methods));
6463
}
6564

66-
public ServiceDescriptor(String name, Object attachedObject,
65+
/** Creates a new ServiceDescriptor. */
66+
public ServiceDescriptor(String name, Object marshallerDescriptor,
6767
Collection<MethodDescriptor<?, ?>> methods) {
68-
this(name, methods);
69-
this.attachedObject = attachedObject;
68+
this.name = Preconditions.checkNotNull(name, "name");
69+
this.marshallerDescriptor = marshallerDescriptor;
70+
this.methods = Collections.unmodifiableList(new ArrayList<MethodDescriptor<?, ?>>(methods));
7071
}
7172

7273
/** Simple name of the service. It is not an absolute path. */
@@ -83,11 +84,12 @@ public String getName() {
8384
}
8485

8586
/**
86-
* The generated code may attach an object to a service descriptor, such as the proto codegen
87-
* attaching a object that allows retrieving the underlying proto object.
87+
* Returns a marshaller-specific object that provides additional information about the service.
88+
* For example, when using Protobuf this should generally be a
89+
* {@link io.grpc.protobuf.reflection.ProtoFileDescriptorWrapper}, when present.
8890
*/
8991
@Nullable
90-
public Object getAttachedObject() {
91-
return attachedObject;
92+
public Object getMarshallerDescriptor() {
93+
return marshallerDescriptor;
9294
}
9395
}

grpclb/src/generated/main/grpc/io/grpc/grpclb/LoadBalancerGrpc.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public io.grpc.stub.StreamObserver<Req> invoke(
193193
}
194194
}
195195

196-
public static final class LoadBalancerDescriptorWrapper implements io.grpc.protobuf.reflection.ProtoFileDescriptorWrapper {
196+
private static final class LoadBalancerDescriptorSupplier implements io.grpc.protobuf.ProtoFileDescriptorSupplier {
197197
@java.lang.Override
198198
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
199199
return io.grpc.grpclb.LoadBalancerProto.getDescriptor();
@@ -205,7 +205,7 @@ public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
205205
public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() {
206206
if (serviceDescriptor == null) {
207207
serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME,
208-
new LoadBalancerDescriptorWrapper(),
208+
new LoadBalancerDescriptorSupplier(),
209209
METHOD_BALANCE_LOAD);
210210
}
211211

interop-testing/src/generated/main/grpc/io/grpc/testing/integration/MetricsServiceGrpc.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ public io.grpc.stub.StreamObserver<Req> invoke(
271271
}
272272
}
273273

274-
public static final class MetricsServiceDescriptorWrapper implements io.grpc.protobuf.reflection.ProtoFileDescriptorWrapper {
274+
private static final class MetricsServiceDescriptorSupplier implements io.grpc.protobuf.ProtoFileDescriptorSupplier {
275275
@java.lang.Override
276276
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
277277
return io.grpc.testing.integration.Metrics.getDescriptor();
@@ -283,7 +283,7 @@ public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
283283
public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() {
284284
if (serviceDescriptor == null) {
285285
serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME,
286-
new MetricsServiceDescriptorWrapper(),
286+
new MetricsServiceDescriptorSupplier(),
287287
METHOD_GET_ALL_GAUGES,
288288
METHOD_GET_GAUGE);
289289
}

interop-testing/src/generated/main/grpc/io/grpc/testing/integration/ReconnectServiceGrpc.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ public io.grpc.stub.StreamObserver<Req> invoke(
269269
}
270270
}
271271

272-
public static final class ReconnectServiceDescriptorWrapper implements io.grpc.protobuf.reflection.ProtoFileDescriptorWrapper {
272+
private static final class ReconnectServiceDescriptorSupplier implements io.grpc.protobuf.ProtoFileDescriptorSupplier {
273273
@java.lang.Override
274274
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
275275
return io.grpc.testing.integration.Test.getDescriptor();
@@ -281,7 +281,7 @@ public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
281281
public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() {
282282
if (serviceDescriptor == null) {
283283
serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME,
284-
new ReconnectServiceDescriptorWrapper(),
284+
new ReconnectServiceDescriptorSupplier(),
285285
METHOD_START,
286286
METHOD_STOP);
287287
}

interop-testing/src/generated/main/grpc/io/grpc/testing/integration/TestServiceGrpc.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ public io.grpc.stub.StreamObserver<Req> invoke(
556556
}
557557
}
558558

559-
public static final class TestServiceDescriptorWrapper implements io.grpc.protobuf.reflection.ProtoFileDescriptorWrapper {
559+
private static final class TestServiceDescriptorSupplier implements io.grpc.protobuf.ProtoFileDescriptorSupplier {
560560
@java.lang.Override
561561
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
562562
return io.grpc.testing.integration.Test.getDescriptor();
@@ -568,7 +568,7 @@ public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
568568
public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() {
569569
if (serviceDescriptor == null) {
570570
serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME,
571-
new TestServiceDescriptorWrapper(),
571+
new TestServiceDescriptorSupplier(),
572572
METHOD_EMPTY_CALL,
573573
METHOD_UNARY_CALL,
574574
METHOD_STREAMING_OUTPUT_CALL,

interop-testing/src/generated/main/grpc/io/grpc/testing/integration/UnimplementedServiceGrpc.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ public io.grpc.stub.StreamObserver<Req> invoke(
235235
}
236236
}
237237

238-
public static final class UnimplementedServiceDescriptorWrapper implements io.grpc.protobuf.reflection.ProtoFileDescriptorWrapper {
238+
private static final class UnimplementedServiceDescriptorSupplier implements io.grpc.protobuf.ProtoFileDescriptorSupplier {
239239
@java.lang.Override
240240
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
241241
return io.grpc.testing.integration.Test.getDescriptor();
@@ -247,7 +247,7 @@ public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
247247
public static synchronized io.grpc.ServiceDescriptor getServiceDescriptor() {
248248
if (serviceDescriptor == null) {
249249
serviceDescriptor = new io.grpc.ServiceDescriptor(SERVICE_NAME,
250-
new UnimplementedServiceDescriptorWrapper(),
250+
new UnimplementedServiceDescriptorSupplier(),
251251
METHOD_UNIMPLEMENTED_CALL);
252252
}
253253

0 commit comments

Comments
 (0)