From 6ff509c32a781eede0e246a0593f6e753fb25d05 Mon Sep 17 00:00:00 2001 From: Mingliang Liu Date: Tue, 18 Sep 2018 10:20:15 -0700 Subject: [PATCH] HDFS-11719. Arrays.fill() wrong index in BlockSender.readChecksum() exception handling. Contributed by Tao Zhang --- .../apache/hadoop/hdfs/server/datanode/BlockSender.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockSender.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockSender.java index 268007f0532..bff47fa6ba6 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockSender.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockSender.java @@ -682,16 +682,17 @@ class BlockSender implements java.io.Closeable { + " at offset " + offset + " for block " + block, e); ris.closeChecksumStream(); if (corruptChecksumOk) { - if (checksumOffset < checksumLen) { + if (checksumLen > 0) { // Just fill the array with zeros. - Arrays.fill(buf, checksumOffset, checksumLen, (byte) 0); + Arrays.fill(buf, checksumOffset, checksumOffset + checksumLen, + (byte) 0); } } else { throw e; } } } - + /** * Compute checksum for chunks and verify the checksum that is read from * the metadata file is correct.