diff --git a/interop-testing/src/main/java/io/grpc/testing/integration/XdsTestClient.java b/interop-testing/src/main/java/io/grpc/testing/integration/XdsTestClient.java index 67ad40674e..66d061b766 100644 --- a/interop-testing/src/main/java/io/grpc/testing/integration/XdsTestClient.java +++ b/interop-testing/src/main/java/io/grpc/testing/integration/XdsTestClient.java @@ -208,17 +208,17 @@ public final class XdsTestClient { CallOptions.DEFAULT.withDeadlineAfter(rpcTimeoutSec, TimeUnit.SECONDS)); call.start( new ClientCall.Listener() { - private String serverId; + private String hostname; @Override public void onMessage(SimpleResponse response) { - serverId = response.getServerId(); + hostname = response.getHostname(); // TODO(ericgribkoff) Currently some test environments cannot access the stats RPC // service and rely on parsing stdout. if (printResponse) { System.out.println( "Greeting: Hello world, this is " - + response.getHostname() + + hostname + ", from " + call.getAttributes().get(Grpc.TRANSPORT_ATTR_REMOTE_ADDR)); } @@ -227,7 +227,7 @@ public final class XdsTestClient { @Override public void onClose(Status status, Metadata trailers) { for (XdsStatsWatcher watcher : savedWatchers) { - watcher.rpcCompleted(requestId, serverId); + watcher.rpcCompleted(requestId, hostname); } } }, @@ -295,14 +295,14 @@ public final class XdsTestClient { this.endId = endId; } - void rpcCompleted(long requestId, @Nullable String serverId) { + void rpcCompleted(long requestId, @Nullable String hostname) { synchronized (lock) { if (startId <= requestId && requestId < endId) { - if (serverId != null) { - if (rpcsByPeer.containsKey(serverId)) { - rpcsByPeer.put(serverId, rpcsByPeer.get(serverId) + 1); + if (hostname != null) { + if (rpcsByPeer.containsKey(hostname)) { + rpcsByPeer.put(hostname, rpcsByPeer.get(hostname) + 1); } else { - rpcsByPeer.put(serverId, 1); + rpcsByPeer.put(hostname, 1); } } else { noRemotePeer += 1; diff --git a/interop-testing/src/main/java/io/grpc/testing/integration/XdsTestServer.java b/interop-testing/src/main/java/io/grpc/testing/integration/XdsTestServer.java index e3ae481142..915be98a40 100644 --- a/interop-testing/src/main/java/io/grpc/testing/integration/XdsTestServer.java +++ b/interop-testing/src/main/java/io/grpc/testing/integration/XdsTestServer.java @@ -124,13 +124,14 @@ public final class XdsTestServer { } private class TestServiceImpl extends TestServiceGrpc.TestServiceImplBase { - private String host = ""; + private final String host; private TestServiceImpl() { try { host = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { - logger.log(Level.WARNING, "Failed to get host", e); + logger.log(Level.SEVERE, "Failed to get host", e); + throw new RuntimeException(e); } }