Переглянути джерело

HDFS-6885. Fix wrong use of BytesWritable in FSEditLogOp#RenameOp. Contributed by Yi Liu.

Haohui Mai 9 роки тому
батько
коміт
8aa12772d4

+ 3 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

@@ -1487,6 +1487,9 @@ Release 2.8.0 - UNRELEASED
     HDFS-8914. Document HA support in the HDFS HdfsDesign.md.
     (Lars Francke via wheat9)
 
+    HDFS-6885. Fix wrong use of BytesWritable in FSEditLogOp#RenameOp.
+    (Yi Liu via wheat9)
+
 Release 2.7.3 - UNRELEASED
 
   INCOMPATIBLE CHANGES

+ 3 - 2
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java

@@ -2707,9 +2707,10 @@ public abstract class FSEditLogOp {
       writable.readFields(in);
 
       byte[] bytes = writable.getBytes();
-      Rename[] options = new Rename[bytes.length];
+      int len = writable.getLength();
+      Rename[] options = new Rename[len];
 
-      for (int i = 0; i < bytes.length; i++) {
+      for (int i = 0; i < len; i++) {
         options[i] = Rename.valueOf(bytes[i]);
       }
       return options;