Skip to content

Commit eb97207

Browse files
committed
Remove blocking from the creating a V2 ServerStreaming RPC which eliminates it throwing an exception.
1 parent b7e1aea commit eb97207

File tree

12 files changed

+17
-35
lines changed

12 files changed

+17
-35
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,7 @@ public io.grpc.benchmarks.proto.Messages.SimpleResponse unaryCall(io.grpc.benchm
441441
*/
442442
@io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/10918")
443443
public io.grpc.stub.BlockingClientCall<?, io.grpc.benchmarks.proto.Messages.SimpleResponse>
444-
streamingFromServer(io.grpc.benchmarks.proto.Messages.SimpleRequest request) throws java.lang.InterruptedException,
445-
io.grpc.StatusException {
444+
streamingFromServer(io.grpc.benchmarks.proto.Messages.SimpleRequest request) {
446445
return io.grpc.stub.ClientCalls.blockingV2ServerStreamingCall(
447446
getChannel(), getStreamingFromServerMethod(), getCallOptions(), request);
448447
}

compiler/src/java_plugin/cpp/java_generator.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,8 +741,7 @@ static void PrintStub(
741741
p->Print(
742742
*vars,
743743
"$BlockingClientCall$<?, $output_type$>\n"
744-
" $lower_method_name$($input_type$ request) throws java.lang.InterruptedException,\n"
745-
" io.grpc.StatusException");
744+
" $lower_method_name$($input_type$ request)");
746745
} else {
747746
// Simple RPC
748747
p->Print(

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,8 +593,7 @@ public final class TestServiceGrpc {
593593
*/
594594
@io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/10918")
595595
public io.grpc.stub.BlockingClientCall<?, io.grpc.testing.compiler.Test.StreamingOutputCallResponse>
596-
streamingOutputCall(io.grpc.testing.compiler.Test.StreamingOutputCallRequest request) throws java.lang.InterruptedException,
597-
io.grpc.StatusException {
596+
streamingOutputCall(io.grpc.testing.compiler.Test.StreamingOutputCallRequest request) {
598597
return io.grpc.stub.ClientCalls.blockingV2ServerStreamingCall(
599598
getChannel(), getStreamingOutputCallMethod(), getCallOptions(), request);
600599
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,8 +582,7 @@ public final class TestServiceGrpc {
582582
*/
583583
@io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/10918")
584584
public io.grpc.stub.BlockingClientCall<?, io.grpc.testing.compiler.Test.StreamingOutputCallResponse>
585-
streamingOutputCall(io.grpc.testing.compiler.Test.StreamingOutputCallRequest request) throws java.lang.InterruptedException,
586-
io.grpc.StatusException {
585+
streamingOutputCall(io.grpc.testing.compiler.Test.StreamingOutputCallRequest request) {
587586
return io.grpc.stub.ClientCalls.blockingV2ServerStreamingCall(
588587
getChannel(), getStreamingOutputCallMethod(), getCallOptions(), request);
589588
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,7 @@ protected MetricsServiceBlockingV2Stub build(
237237
*/
238238
@io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/10918")
239239
public io.grpc.stub.BlockingClientCall<?, io.grpc.testing.integration.Metrics.GaugeResponse>
240-
getAllGauges(io.grpc.testing.integration.Metrics.EmptyMessage request) throws java.lang.InterruptedException,
241-
io.grpc.StatusException {
240+
getAllGauges(io.grpc.testing.integration.Metrics.EmptyMessage request) {
242241
return io.grpc.stub.ClientCalls.blockingV2ServerStreamingCall(
243242
getChannel(), getGetAllGaugesMethod(), getCallOptions(), request);
244243
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,8 +619,7 @@ public io.grpc.testing.integration.Messages.SimpleResponse cacheableUnaryCall(io
619619
*/
620620
@io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/10918")
621621
public io.grpc.stub.BlockingClientCall<?, io.grpc.testing.integration.Messages.StreamingOutputCallResponse>
622-
streamingOutputCall(io.grpc.testing.integration.Messages.StreamingOutputCallRequest request) throws java.lang.InterruptedException,
623-
io.grpc.StatusException {
622+
streamingOutputCall(io.grpc.testing.integration.Messages.StreamingOutputCallRequest request) {
624623
return io.grpc.stub.ClientCalls.blockingV2ServerStreamingCall(
625624
getChannel(), getStreamingOutputCallMethod(), getCallOptions(), request);
626625
}

s2a/src/generated/main/grpc/io/grpc/s2a/internal/handshaker/S2AServiceGrpc.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ protected S2AServiceBlockingV2Stub build(
184184
* </pre>
185185
*/
186186
@io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/10918")
187-
public io.grpc.stub.BlockingClientCall<io.grpc.s2a.handshaker.SessionReq, io.grpc.s2a.handshaker.SessionResp>
187+
public io.grpc.stub.BlockingClientCall<io.grpc.s2a.internal.handshaker.SessionReq, io.grpc.s2a.internal.handshaker.SessionResp>
188188
setUpSession() {
189189
return io.grpc.stub.ClientCalls.blockingBidiStreamingCall(
190190
getChannel(), getSetUpSessionMethod(), getCallOptions());

services/src/generated/main/grpc/io/grpc/health/v1/HealthGrpc.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,7 @@ public io.grpc.health.v1.HealthCheckResponse check(io.grpc.health.v1.HealthCheck
283283
*/
284284
@io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/10918")
285285
public io.grpc.stub.BlockingClientCall<?, io.grpc.health.v1.HealthCheckResponse>
286-
watch(io.grpc.health.v1.HealthCheckRequest request) throws java.lang.InterruptedException,
287-
io.grpc.StatusException {
286+
watch(io.grpc.health.v1.HealthCheckRequest request) {
288287
return io.grpc.stub.ClientCalls.blockingV2ServerStreamingCall(
289288
getChannel(), getWatchMethod(), getCallOptions(), request);
290289
}

stub/src/main/java/io/grpc/stub/BlockingClientCall.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,10 @@ private boolean write(boolean waitForever, ReqT request, long timeout, TimeUnit
238238
}
239239
}
240240

241+
void sendSingleRequest(ReqT request) {
242+
call.sendMessage(request);
243+
}
244+
241245
/**
242246
* Cancel stream and stop any further writes. Note that some reads that are in flight may still
243247
* happen after the cancel.

stub/src/main/java/io/grpc/stub/ClientCalls.java

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -220,35 +220,22 @@ public static <ReqT, RespT> Iterator<RespT> blockingServerStreamingCall(
220220

221221
/**
222222
* Initiates a client streaming call over the specified channel. It returns an
223-
* object which can be used in a blocking manner to send values to the server and retrieve a
224-
* response.
225-
*
226-
* <p>Call {@link BlockingClientCall#write} for each value to send to the server. After the last
227-
* value has been written, call {@link BlockingClientCall#halfClose} to indicate that writing is
228-
* complete and then {@link BlockingClientCall#read} to get the response.
223+
* object which can be used in a blocking manner to retrieve responses..
229224
*
230225
* <p>The methods {@link BlockingClientCall#hasNext()} and {@link
231226
* BlockingClientCall#cancel(String, Throwable)} can be used for more extensive control.
232227
*
233228
* @return A {@link BlockingClientCall} that has had the request sent and halfClose called
234-
* @throws InterruptedException if it receives an interrupt while sending the request
235-
* @throws StatusException if the write to the server failed
236229
*/
237230
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/10918")
238231
public static <ReqT, RespT> BlockingClientCall<ReqT, RespT> blockingV2ServerStreamingCall(
239-
Channel channel, MethodDescriptor<ReqT, RespT> method, CallOptions callOptions, ReqT req)
240-
throws InterruptedException, StatusException {
232+
Channel channel, MethodDescriptor<ReqT, RespT> method, CallOptions callOptions, ReqT req) {
241233
BlockingClientCall<ReqT, RespT> call =
242234
blockingBidiStreamingCall(channel, method, callOptions);
243235

244-
try {
245-
call.write(req);
236+
call.sendSingleRequest(req);
246237
call.halfClose();
247238
return call;
248-
} catch (InterruptedException e) {
249-
call.cancel("Interrupted while writing request", e);
250-
throw e;
251-
}
252239
}
253240

254241
/**

0 commit comments

Comments
 (0)