diff --git a/CHANGES.txt b/CHANGES.txt index b54723d9bcc..65c4823c347 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -84,6 +84,9 @@ Trunk (unreleased changes) HADOOP-6620. NPE if renewer is passed as null in getDelegationToken. (Jitendra Pandey via jghoman) + HADOOP-6613. Moves the RPC version check ahead of the AuthMethod check. + (Kan Zhang via ddas) + Release 0.21.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 194bb430fff..f3cd00ac30f 100644 --- a/src/java/org/apache/hadoop/ipc/Server.java +++ b/src/java/org/apache/hadoop/ipc/Server.java @@ -1088,6 +1088,16 @@ public abstract class Server { byte[] method = new byte[] {rpcHeaderBuffer.get(1)}; authMethod = AuthMethod.read(new DataInputStream( new ByteArrayInputStream(method))); + dataLengthBuffer.flip(); + if (!HEADER.equals(dataLengthBuffer) || version != CURRENT_VERSION) { + //Warning is ok since this is not supposed to happen. + LOG.warn("Incorrect header or version mismatch from " + + hostAddress + ":" + remotePort + + " got version " + version + + " expected version " + CURRENT_VERSION); + return -1; + } + dataLengthBuffer.clear(); if (authMethod == null) { throw new IOException("Unable to read authentication method"); } @@ -1112,16 +1122,6 @@ public abstract class Server { useSasl = true; } - dataLengthBuffer.flip(); - if (!HEADER.equals(dataLengthBuffer) || version != CURRENT_VERSION) { - //Warning is ok since this is not supposed to happen. - LOG.warn("Incorrect header or version mismatch from " + - hostAddress + ":" + remotePort + - " got version " + version + - " expected version " + CURRENT_VERSION); - return -1; - } - dataLengthBuffer.clear(); rpcHeaderBuffer = null; rpcHeaderRead = true; continue;