Index: hbase-server/src/main/java/org/apache/hadoop/hbase/io/FSDataInputStreamWrapper.java =================================================================== --- hbase-server/src/main/java/org/apache/hadoop/hbase/io/FSDataInputStreamWrapper.java (revision 1539492) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/io/FSDataInputStreamWrapper.java (working copy) @@ -70,6 +70,7 @@ // value as useHBaseChecksumConfigured, but can change state as and when // we encounter checksum verification failures. private volatile boolean useHBaseChecksum; + private volatile boolean waitingForStream; // In the case of a checksum failure, do these many succeeding // reads without hbase checksum verification. @@ -115,6 +116,7 @@ this.streamNoFsChecksum = (link != null) ? link.open(fsNc) : fsNc.open(path); this.useHBaseChecksumConfigured = this.useHBaseChecksum = useHBaseChecksum; // Close the checksum stream; we will reopen it if we get an HBase checksum failure. + if (waitingForStream) throw new NullPointerException("stream not returned"); this.stream.close(); this.stream = null; } @@ -142,6 +144,8 @@ * @return Whether we are presently using HBase checksum. */ public boolean shouldUseHBaseChecksum() { + assert waitingForStream == false; + waitingForStream = true; return this.useHBaseChecksum; } @@ -151,6 +155,7 @@ * at some point in the past, otherwise the result is undefined. */ public FSDataInputStream getStream(boolean useHBaseChecksum) { + waitingForStream = false; return useHBaseChecksum ? this.streamNoFsChecksum : this.stream; } @@ -189,6 +194,7 @@ /** Close stream(s) if necessary. */ public void close() throws IOException { if (!doCloseStreams) return; + if (waitingForStream) throw new NullPointerException("stream not returned"); try { if (stream != streamNoFsChecksum && streamNoFsChecksum != null) { streamNoFsChecksum.close();