From 5bb47d041893bd63c18e497c718ed7893d1aec97 Mon Sep 17 00:00:00 2001 From: Vinayakumar B Date: Mon, 17 Nov 2014 20:19:19 +0530 Subject: [PATCH] HDFS-7399. Lack of synchronization in DFSOutputStream#Packet#getLastByteOffsetBlock() (Contributed by Vinayakumar B) (cherry picked from commit 6783d17fcf5b25165767888f756a6b7802ab1371) --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../main/java/org/apache/hadoop/hdfs/DFSOutputStream.java | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 694be33724a..035739820bf 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -178,6 +178,9 @@ Release 2.7.0 - UNRELEASED HDFS-7395. BlockIdManager#clear() bails out when resetting the GenerationStampV1Limit. (wheat9) + HDFS-7399. Lack of synchronization in + DFSOutputStream#Packet#getLastByteOffsetBlock() (vinayakumarb) + Release 2.6.0 - 2014-11-18 INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSOutputStream.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSOutputStream.java index 8f18afe719f..e21badfbc71 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSOutputStream.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSOutputStream.java @@ -342,12 +342,12 @@ public class DFSOutputStream extends FSOutputSummer bam.release(buf); buf = null; } - + // get the packet's last byte's offset in the block - long getLastByteOffsetBlock() { + synchronized long getLastByteOffsetBlock() { return offsetInBlock + dataPos - dataStart; } - + /** * Check if this packet is a heart beat packet * @return true if the sequence number is HEART_BEAT_SEQNO