mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-03 12:21:23 +00:00
Fix Java generator bug that ignores bidi streaming attribute (#5063)
* Fix Java generator bug that ignores streaming: bidi attribute Tests * Java gRPC client streaming test * Java gRPC Bidi Streaming Test
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
0143f4e364
commit
9635d494b3
@@ -128,6 +128,72 @@ public final class MonsterStorageGrpc {
|
||||
return getRetrieveMethod;
|
||||
}
|
||||
|
||||
@io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
|
||||
@java.lang.Deprecated // Use {@link #getGetMaxHitPointMethod()} instead.
|
||||
public static final io.grpc.MethodDescriptor<MyGame.Example.Monster,
|
||||
MyGame.Example.Stat> METHOD_GET_MAX_HIT_POINT = getGetMaxHitPointMethod();
|
||||
|
||||
private static volatile io.grpc.MethodDescriptor<MyGame.Example.Monster,
|
||||
MyGame.Example.Stat> getGetMaxHitPointMethod;
|
||||
|
||||
@io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
|
||||
public static io.grpc.MethodDescriptor<MyGame.Example.Monster,
|
||||
MyGame.Example.Stat> getGetMaxHitPointMethod() {
|
||||
io.grpc.MethodDescriptor<MyGame.Example.Monster, MyGame.Example.Stat> getGetMaxHitPointMethod;
|
||||
if ((getGetMaxHitPointMethod = MonsterStorageGrpc.getGetMaxHitPointMethod) == null) {
|
||||
synchronized (MonsterStorageGrpc.class) {
|
||||
if ((getGetMaxHitPointMethod = MonsterStorageGrpc.getGetMaxHitPointMethod) == null) {
|
||||
MonsterStorageGrpc.getGetMaxHitPointMethod = getGetMaxHitPointMethod =
|
||||
io.grpc.MethodDescriptor.<MyGame.Example.Monster, MyGame.Example.Stat>newBuilder()
|
||||
.setType(io.grpc.MethodDescriptor.MethodType.CLIENT_STREAMING)
|
||||
.setFullMethodName(generateFullMethodName(
|
||||
"MyGame.Example.MonsterStorage", "GetMaxHitPoint"))
|
||||
.setSampledToLocalTracing(true)
|
||||
.setRequestMarshaller(FlatbuffersUtils.marshaller(
|
||||
MyGame.Example.Monster.class, getExtractorOfMonster()))
|
||||
.setResponseMarshaller(FlatbuffersUtils.marshaller(
|
||||
MyGame.Example.Stat.class, getExtractorOfStat()))
|
||||
.setSchemaDescriptor(null)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
return getGetMaxHitPointMethod;
|
||||
}
|
||||
|
||||
@io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
|
||||
@java.lang.Deprecated // Use {@link #getGetMinMaxHitPointsMethod()} instead.
|
||||
public static final io.grpc.MethodDescriptor<MyGame.Example.Monster,
|
||||
MyGame.Example.Stat> METHOD_GET_MIN_MAX_HIT_POINTS = getGetMinMaxHitPointsMethod();
|
||||
|
||||
private static volatile io.grpc.MethodDescriptor<MyGame.Example.Monster,
|
||||
MyGame.Example.Stat> getGetMinMaxHitPointsMethod;
|
||||
|
||||
@io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
|
||||
public static io.grpc.MethodDescriptor<MyGame.Example.Monster,
|
||||
MyGame.Example.Stat> getGetMinMaxHitPointsMethod() {
|
||||
io.grpc.MethodDescriptor<MyGame.Example.Monster, MyGame.Example.Stat> getGetMinMaxHitPointsMethod;
|
||||
if ((getGetMinMaxHitPointsMethod = MonsterStorageGrpc.getGetMinMaxHitPointsMethod) == null) {
|
||||
synchronized (MonsterStorageGrpc.class) {
|
||||
if ((getGetMinMaxHitPointsMethod = MonsterStorageGrpc.getGetMinMaxHitPointsMethod) == null) {
|
||||
MonsterStorageGrpc.getGetMinMaxHitPointsMethod = getGetMinMaxHitPointsMethod =
|
||||
io.grpc.MethodDescriptor.<MyGame.Example.Monster, MyGame.Example.Stat>newBuilder()
|
||||
.setType(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
|
||||
.setFullMethodName(generateFullMethodName(
|
||||
"MyGame.Example.MonsterStorage", "GetMinMaxHitPoints"))
|
||||
.setSampledToLocalTracing(true)
|
||||
.setRequestMarshaller(FlatbuffersUtils.marshaller(
|
||||
MyGame.Example.Monster.class, getExtractorOfMonster()))
|
||||
.setResponseMarshaller(FlatbuffersUtils.marshaller(
|
||||
MyGame.Example.Stat.class, getExtractorOfStat()))
|
||||
.setSchemaDescriptor(null)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
return getGetMinMaxHitPointsMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new async stub that supports all call types for the service
|
||||
*/
|
||||
@@ -169,6 +235,20 @@ public final class MonsterStorageGrpc {
|
||||
asyncUnimplementedUnaryCall(getRetrieveMethod(), responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public io.grpc.stub.StreamObserver<MyGame.Example.Monster> getMaxHitPoint(
|
||||
io.grpc.stub.StreamObserver<MyGame.Example.Stat> responseObserver) {
|
||||
return asyncUnimplementedStreamingCall(getGetMaxHitPointMethod(), responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public io.grpc.stub.StreamObserver<MyGame.Example.Monster> getMinMaxHitPoints(
|
||||
io.grpc.stub.StreamObserver<MyGame.Example.Stat> responseObserver) {
|
||||
return asyncUnimplementedStreamingCall(getGetMinMaxHitPointsMethod(), responseObserver);
|
||||
}
|
||||
|
||||
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
|
||||
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
|
||||
.addMethod(
|
||||
@@ -185,6 +265,20 @@ public final class MonsterStorageGrpc {
|
||||
MyGame.Example.Stat,
|
||||
MyGame.Example.Monster>(
|
||||
this, METHODID_RETRIEVE)))
|
||||
.addMethod(
|
||||
getGetMaxHitPointMethod(),
|
||||
asyncClientStreamingCall(
|
||||
new MethodHandlers<
|
||||
MyGame.Example.Monster,
|
||||
MyGame.Example.Stat>(
|
||||
this, METHODID_GET_MAX_HIT_POINT)))
|
||||
.addMethod(
|
||||
getGetMinMaxHitPointsMethod(),
|
||||
asyncBidiStreamingCall(
|
||||
new MethodHandlers<
|
||||
MyGame.Example.Monster,
|
||||
MyGame.Example.Stat>(
|
||||
this, METHODID_GET_MIN_MAX_HIT_POINTS)))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -222,6 +316,22 @@ public final class MonsterStorageGrpc {
|
||||
asyncServerStreamingCall(
|
||||
getChannel().newCall(getRetrieveMethod(), getCallOptions()), request, responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public io.grpc.stub.StreamObserver<MyGame.Example.Monster> getMaxHitPoint(
|
||||
io.grpc.stub.StreamObserver<MyGame.Example.Stat> responseObserver) {
|
||||
return asyncClientStreamingCall(
|
||||
getChannel().newCall(getGetMaxHitPointMethod(), getCallOptions()), responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public io.grpc.stub.StreamObserver<MyGame.Example.Monster> getMinMaxHitPoints(
|
||||
io.grpc.stub.StreamObserver<MyGame.Example.Stat> responseObserver) {
|
||||
return asyncBidiStreamingCall(
|
||||
getChannel().newCall(getGetMinMaxHitPointsMethod(), getCallOptions()), responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -287,6 +397,8 @@ public final class MonsterStorageGrpc {
|
||||
|
||||
private static final int METHODID_STORE = 0;
|
||||
private static final int METHODID_RETRIEVE = 1;
|
||||
private static final int METHODID_GET_MIN_MAX_HIT_POINTS = 2;
|
||||
private static final int METHODID_GET_MAX_HIT_POINT = 3;
|
||||
|
||||
private static final class MethodHandlers<Req, Resp> implements
|
||||
io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
|
||||
@@ -323,6 +435,12 @@ public final class MonsterStorageGrpc {
|
||||
public io.grpc.stub.StreamObserver<Req> invoke(
|
||||
io.grpc.stub.StreamObserver<Resp> responseObserver) {
|
||||
switch (methodId) {
|
||||
case METHODID_GET_MAX_HIT_POINT:
|
||||
return (io.grpc.stub.StreamObserver<Req>) serviceImpl.getMaxHitPoint(
|
||||
(io.grpc.stub.StreamObserver<MyGame.Example.Stat>) responseObserver);
|
||||
case METHODID_GET_MIN_MAX_HIT_POINTS:
|
||||
return (io.grpc.stub.StreamObserver<Req>) serviceImpl.getMinMaxHitPoints(
|
||||
(io.grpc.stub.StreamObserver<MyGame.Example.Stat>) responseObserver);
|
||||
default:
|
||||
throw new AssertionError();
|
||||
}
|
||||
@@ -341,6 +459,8 @@ public final class MonsterStorageGrpc {
|
||||
.setSchemaDescriptor(null)
|
||||
.addMethod(getStoreMethod())
|
||||
.addMethod(getRetrieveMethod())
|
||||
.addMethod(getGetMaxHitPointMethod())
|
||||
.addMethod(getGetMinMaxHitPointsMethod())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user