From 8fa094ad6ad3b4f8a3102b79d4e36146f53abea8 Mon Sep 17 00:00:00 2001 From: Devaraj Das Date: Sat, 12 Jun 2010 00:13:15 +0000 Subject: [PATCH] HADOOP-6613. Moves the RPC version check ahead of the AuthMethod check. Contributed by Kan Zhang. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@953910 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 3 +++ src/java/org/apache/hadoop/ipc/Server.java | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index b54723d9bc..65c4823c34 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 194bb430ff..f3cd00ac30 100644 --- a/src/java/org/apache/hadoop/ipc/Server.java +++ b/src/java/org/apache/hadoop/ipc/Server.java @@ -1088,6 +1088,16 @@ public int readAndProcess() throws IOException, InterruptedException { 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 int readAndProcess() throws IOException, InterruptedException { 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;