diff --git a/CHANGES.txt b/CHANGES.txt index 1619f6c472..a1d4a9e523 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -226,6 +226,9 @@ Trunk (unreleased changes) HADOOP-7292. Fix racy test case TestSinkQueue. (Luke Lu via todd) + HADOOP-7282. ipc.Server.getRemoteIp() may return null. (John George + via szetszwo) + Release 0.22.0 - Unreleased INCOMPATIBLE CHANGES diff --git a/src/java/org/apache/hadoop/ipc/Server.java b/src/java/org/apache/hadoop/ipc/Server.java index e2dd1f099f..83c5a354eb 100644 --- a/src/java/org/apache/hadoop/ipc/Server.java +++ b/src/java/org/apache/hadoop/ipc/Server.java @@ -154,7 +154,7 @@ public static Server get() { public static InetAddress getRemoteIp() { Call call = CurCall.get(); if (call != null) { - return call.connection.socket.getInetAddress(); + return call.connection.getHostInetAddress(); } return null; } @@ -166,6 +166,13 @@ public static String getRemoteAddress() { return (addr == null) ? null : addr.getHostAddress(); } + + /** Return true if the invocation was through an RPC. + */ + public static boolean isRpcInvocation() { + return CurCall.get() != null; + } + private String bindAddress; private int port; // port we listen on private int handlerCount; // number of handler threads