mirror of https://github.com/grpc/grpc-java.git
api: Allow streaming methods to be safe
This commit is contained in:
parent
ddaf1c8ce9
commit
fa45a71ec9
|
|
@ -234,8 +234,6 @@ public final class MethodDescriptor<ReqT, RespT> {
|
||||||
this.idempotent = idempotent;
|
this.idempotent = idempotent;
|
||||||
this.safe = safe;
|
this.safe = safe;
|
||||||
this.sampledToLocalTracing = sampledToLocalTracing;
|
this.sampledToLocalTracing = sampledToLocalTracing;
|
||||||
Preconditions.checkArgument(!safe || type == MethodType.UNARY,
|
|
||||||
"Only unary methods can be specified safe");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -102,8 +102,9 @@ public class MethodDescriptorTest {
|
||||||
.setResponseMarshaller(new StringMarshaller())
|
.setResponseMarshaller(new StringMarshaller())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
thrown.expect(IllegalArgumentException.class);
|
// Verify it does not throw
|
||||||
MethodDescriptor<String, String> unused = descriptor.toBuilder().setSafe(true).build();
|
MethodDescriptor<String, String> newDescriptor = descriptor.toBuilder().setSafe(true).build();
|
||||||
|
assertTrue(newDescriptor.isSafe());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue