diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/KeyValueHeap.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/KeyValueHeap.java index 053ae997c74..b0f42d7e1f3 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/KeyValueHeap.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/KeyValueHeap.java @@ -224,8 +224,8 @@ public class KeyValueHeap extends NonReversedNonLazyKeyValueScanner this.current.close(); } if (this.heap != null) { - KeyValueScanner scanner; - while ((scanner = this.heap.poll()) != null) { + // Order of closing the scanners shouldn't matter here, so simply iterate and close them. + for (KeyValueScanner scanner : heap) { scanner.close(); } }