Skip to content

Commit da19b28

Browse files
committed
Merge branch 'authoritychecktls-fork' into authoritychecktls
# Conflicts: # examples/example-tls/src/main/java/io/grpc/examples/helloworldtls/HelloWorldClientTls.java
2 parents 4c50e71 + 7fcd98d commit da19b28

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

examples/example-tls/src/main/java/io/grpc/examples/helloworldtls/HelloWorldClientTls.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import static io.grpc.examples.helloworld.GreeterGrpc.getSayHelloMethod;
2020

21+
import io.grpc.CallOptions;
2122
import io.grpc.Channel;
2223
import io.grpc.Grpc;
2324
import io.grpc.ManagedChannel;
@@ -27,6 +28,7 @@
2728
import io.grpc.examples.helloworld.HelloReply;
2829
import io.grpc.examples.helloworld.HelloRequest;
2930
import java.io.File;
31+
import java.io.IOException;
3032
import java.util.concurrent.TimeUnit;
3133
import java.util.logging.Level;
3234
import java.util.logging.Logger;
@@ -50,13 +52,15 @@ public HelloWorldClientTls(Channel channel) {
5052
* Say hello to server.
5153
*/
5254
public void greet(String name) {
53-
System.setProperty("GRPC_ENABLE_PER_RPC_AUTHORITY_CHECK", "true");
5455
logger.info("Will try to greet " + name + " ...");
5556
HelloRequest request = HelloRequest.newBuilder().setName(name).build();
5657
HelloReply response;
5758
try {
59+
CallOptions callOptions = blockingStub.getCallOptions()
60+
.withAuthority("moo.test.goog.fr");
5861
response = io.grpc.stub.ClientCalls.blockingUnaryCall(
59-
blockingStub.getChannel(), getSayHelloMethod(), blockingStub.getCallOptions().withAuthority("foo.goog.test.in"), request);
62+
blockingStub.getChannel(), getSayHelloMethod(),
63+
callOptions, request);
6064
} catch (StatusRuntimeException e) {
6165
logger.log(Level.WARNING, "RPC failed: {0}", e.getStatus());
6266
return;

0 commit comments

Comments
 (0)