Browse Source

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
Devaraj Das 15 years ago
parent
commit
8fa094ad6a
2 changed files with 13 additions and 10 deletions
  1. 3 0
      CHANGES.txt
  2. 10 10
      src/java/org/apache/hadoop/ipc/Server.java

+ 3 - 0
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

+ 10 - 10
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;