Avoid Parser for normal protobuf
Eventually, this could avoid allocating Parser, since we can use
newBuilderForType().mergeFrom(). This would primarily benefit Lite
proto.
diff --git a/compiler/src/java_plugin/cpp/java_generator.cpp b/compiler/src/java_plugin/cpp/java_generator.cpp
index d231394..9daf24c 100644
--- a/compiler/src/java_plugin/cpp/java_generator.cpp
+++ b/compiler/src/java_plugin/cpp/java_generator.cpp
@@ -138,8 +138,8 @@
" $MethodType$.$method_type$,\n"
" generateFullMethodName(\n"
" \"$Package$$service_name$\", \"$method_name$\"),\n"
- " $ProtoUtils$.marshaller($input_type$.parser()),\n"
- " $ProtoUtils$.marshaller($output_type$.parser()));\n");
+ " $ProtoUtils$.marshaller($input_type$.getDefaultInstance()),\n"
+ " $ProtoUtils$.marshaller($output_type$.getDefaultInstance()));\n");
}
}
p->Print("\n");
diff --git a/compiler/src/test/golden/TestService.java.txt b/compiler/src/test/golden/TestService.java.txt
index 9237548..3d6fbed 100644
--- a/compiler/src/test/golden/TestService.java.txt
+++ b/compiler/src/test/golden/TestService.java.txt
@@ -26,8 +26,8 @@
io.grpc.MethodDescriptor.MethodType.UNARY,
generateFullMethodName(
"grpc.testing.TestService", "UnaryCall"),
- io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.SimpleRequest.parser()),
- io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.SimpleResponse.parser()));
+ io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.SimpleRequest.getDefaultInstance()),
+ io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.SimpleResponse.getDefaultInstance()));
@io.grpc.ExperimentalApi
public static final io.grpc.MethodDescriptor<io.grpc.testing.integration.Test.StreamingOutputCallRequest,
io.grpc.testing.integration.Test.StreamingOutputCallResponse> METHOD_STREAMING_OUTPUT_CALL =
@@ -35,8 +35,8 @@
io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING,
generateFullMethodName(
"grpc.testing.TestService", "StreamingOutputCall"),
- io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallRequest.parser()),
- io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallResponse.parser()));
+ io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallRequest.getDefaultInstance()),
+ io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallResponse.getDefaultInstance()));
@io.grpc.ExperimentalApi
public static final io.grpc.MethodDescriptor<io.grpc.testing.integration.Test.StreamingInputCallRequest,
io.grpc.testing.integration.Test.StreamingInputCallResponse> METHOD_STREAMING_INPUT_CALL =
@@ -44,8 +44,8 @@
io.grpc.MethodDescriptor.MethodType.CLIENT_STREAMING,
generateFullMethodName(
"grpc.testing.TestService", "StreamingInputCall"),
- io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingInputCallRequest.parser()),
- io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingInputCallResponse.parser()));
+ io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingInputCallRequest.getDefaultInstance()),
+ io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingInputCallResponse.getDefaultInstance()));
@io.grpc.ExperimentalApi
public static final io.grpc.MethodDescriptor<io.grpc.testing.integration.Test.StreamingOutputCallRequest,
io.grpc.testing.integration.Test.StreamingOutputCallResponse> METHOD_FULL_BIDI_CALL =
@@ -53,8 +53,8 @@
io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING,
generateFullMethodName(
"grpc.testing.TestService", "FullBidiCall"),
- io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallRequest.parser()),
- io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallResponse.parser()));
+ io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallRequest.getDefaultInstance()),
+ io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallResponse.getDefaultInstance()));
@io.grpc.ExperimentalApi
public static final io.grpc.MethodDescriptor<io.grpc.testing.integration.Test.StreamingOutputCallRequest,
io.grpc.testing.integration.Test.StreamingOutputCallResponse> METHOD_HALF_BIDI_CALL =
@@ -62,8 +62,8 @@
io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING,
generateFullMethodName(
"grpc.testing.TestService", "HalfBidiCall"),
- io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallRequest.parser()),
- io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallResponse.parser()));
+ io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallRequest.getDefaultInstance()),
+ io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Test.StreamingOutputCallResponse.getDefaultInstance()));
public static TestServiceStub newStub(io.grpc.Channel channel) {
return new TestServiceStub(channel);