diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/CannotObtainBlockLengthException.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/CannotObtainBlockLengthException.java index 6da1d67b9ae..d6b2856a125 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/CannotObtainBlockLengthException.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/CannotObtainBlockLengthException.java @@ -52,4 +52,16 @@ public class CannotObtainBlockLengthException extends IOException { super("Cannot obtain block length for " + locatedBlock); } + /** + * Constructs an {@code CannotObtainBlockLengthException} with the + * specified LocatedBlock and file that failed to obtain block length. + * + * @param locatedBlock + * The LocatedBlock instance which block length can not be obtained + * @param src The file which include this block + */ + public CannotObtainBlockLengthException(LocatedBlock locatedBlock, + String src) { + super("Cannot obtain block length for " + locatedBlock + " of " + src); + } } diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSInputStream.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSInputStream.java index f877c9dd768..8355cec9377 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSInputStream.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSInputStream.java @@ -364,7 +364,7 @@ public class DFSInputStream extends FSInputStream return 0; } - throw new CannotObtainBlockLengthException(locatedblock); + throw new CannotObtainBlockLengthException(locatedblock, src); } public long getFileLength() {