From e5f0622a6f40706d360d45200c8f259c79046438 Mon Sep 17 00:00:00 2001 From: Mingliang Liu Date: Thu, 30 Mar 2017 15:44:06 -0700 Subject: [PATCH] HDFS-11592. Closing a file has a wasteful preconditions in NameNode. Contributed by Eric Badger --- .../org/apache/hadoop/hdfs/server/namenode/INodeFile.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeFile.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeFile.java index 2b0e0adea2..3da6aa7c81 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeFile.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeFile.java @@ -328,9 +328,11 @@ private void assertAllBlocksComplete(int numCommittedAllowed, for (int i = 0; i < blocks.length; i++) { final String err = checkBlockComplete(blocks, i, numCommittedAllowed, minReplication); - Preconditions.checkState(err == null, - "Unexpected block state: %s, file=%s (%s), blocks=%s (i=%s)", - err, this, getClass().getSimpleName(), Arrays.asList(blocks), i); + if(err != null) { + throw new IllegalStateException(String.format("Unexpected block state: " + + "%s, file=%s (%s), blocks=%s (i=%s)", err, this, + getClass().getSimpleName(), Arrays.asList(blocks), i)); + } } }