Skip to content

Commit 03cf96b

Browse files
author
Steve Vaughan Jr
committed
Add test that updated address is used
Once the address has been updated, it should be used in future calls. Check to ensure that a second request succeeds and that it uses the existing updated address instead of having to re-resolve.
1 parent cac2837 commit 03cf96b

File tree

1 file changed

+10
-0
lines changed
  • hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc

1 file changed

+10
-0
lines changed

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestIPC.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,16 @@ public void testStableHashCode() throws IOException {
858858
assertThat(remoteId.getAddress().getHostName()).isEqualTo(unresolvedAddr.getHostName());
859859
assertThat(remoteId.hashCode()).isEqualTo(expected);
860860

861+
// Test: Call should succeed without having to re-resolve
862+
InetSocketAddress expectedSocketAddress = remoteId.getAddress();
863+
param = new LongWritable(RANDOM.nextLong());
864+
client.call(RPC.RpcKind.RPC_BUILTIN, param, remoteId,
865+
RPC.RPC_SERVICE_CLASS_DEFAULT, null);
866+
867+
// Verify: The same instance of the InetSocketAddress has been used to make the second
868+
// call
869+
assertThat(remoteId.getAddress()).isSameAs(expectedSocketAddress);
870+
861871
// Verify: The hashCode is protected against updates to the host name
862872
String hostName = InetAddress.getLocalHost().getHostName();
863873
InetSocketAddress mismatchedHostName = NetUtils.createSocketAddr(

0 commit comments

Comments
 (0)