From 281c29ff6070e08743ee96b0f7ce916bb1c3bba5 Mon Sep 17 00:00:00 2001 From: Apekshit Sharma Date: Fri, 6 Apr 2018 20:24:45 -0700 Subject: [PATCH] HBASE-20350 NullPointerException in Scanner during close() --- .../org/apache/hadoop/hbase/regionserver/KeyValueHeap.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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(); } }