From 98d9e9c4c823d865ddfc017e71c82d12c8328e53 Mon Sep 17 00:00:00 2001 From: Erik Krogen Date: Sun, 13 Nov 2016 14:50:33 -0800 Subject: [PATCH] HDFS-11087. NamenodeFsck should check if the output writer is still writable. Contributed by Erik Krogen. --- .../apache/hadoop/hdfs/server/namenode/NamenodeFsck.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NamenodeFsck.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NamenodeFsck.java index 6e5a1a48fed..060cfbdc39f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NamenodeFsck.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NamenodeFsck.java @@ -526,7 +526,14 @@ public class NamenodeFsck implements DataEncryptionKeyFactory { } else { out.print('.'); } - if (res.totalFiles % 100 == 0) { out.println(); out.flush(); } + if (res.totalFiles % 100 == 0) { + out.println(); + // checkError here will attempt to flush the stream, or report an error + // if the stream has encountered an error or been closed by the client + if (out.checkError()) { + throw new IOException("fsck encountered an error in its output stream"); + } + } } private void collectBlocksSummary(String parent, HdfsFileStatus file,