From 4123353151c25d95d45f765d57094f5c8e21238c Mon Sep 17 00:00:00 2001 From: Shashikant Banerjee Date: Fri, 1 Feb 2019 20:44:48 +0530 Subject: [PATCH] HDDS-1037. Fix the block discard logic in Ozone client. Contributed by Shashikant Banerjee. --- .../org/apache/hadoop/ozone/client/io/KeyOutputStream.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/io/KeyOutputStream.java b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/io/KeyOutputStream.java index 042aceef1a..af3963100d 100644 --- a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/io/KeyOutputStream.java +++ b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/io/KeyOutputStream.java @@ -338,8 +338,9 @@ private void discardPreallocatedBlocks(long containerID) { ListIterator streamEntryIterator = streamEntries.listIterator(currentStreamIndex); while (streamEntryIterator.hasNext()) { - if (streamEntryIterator.next().getBlockID().getContainerID() - == containerID) { + BlockOutputStreamEntry streamEntry = streamEntryIterator.next(); + if (streamEntry.getBlockID().getContainerID() + == containerID && streamEntry.getCurrentPosition() == 0) { streamEntryIterator.remove(); } }