api: Allow streaming methods to be safe

This commit is contained in:
Eric Anderson 2019-10-16 09:06:47 -07:00
parent ddaf1c8ce9
commit fa45a71ec9
2 changed files with 3 additions and 4 deletions

View File

@ -234,8 +234,6 @@ public final class MethodDescriptor<ReqT, RespT> {
this.idempotent = idempotent;
this.safe = safe;
this.sampledToLocalTracing = sampledToLocalTracing;
Preconditions.checkArgument(!safe || type == MethodType.UNARY,
"Only unary methods can be specified safe");
}
/**

View File

@ -102,8 +102,9 @@ public class MethodDescriptorTest {
.setResponseMarshaller(new StringMarshaller())
.build();
thrown.expect(IllegalArgumentException.class);
MethodDescriptor<String, String> unused = descriptor.toBuilder().setSafe(true).build();
// Verify it does not throw
MethodDescriptor<String, String> newDescriptor = descriptor.toBuilder().setSafe(true).build();
assertTrue(newDescriptor.isSafe());
}
@Test