Apache Solr open-source search software
LUCENE-8709: Handle case of creating a HeapPointWriter with size equal 0
iverase5b2f064ba788
diff --git a/lucene/core/src/java/org/apache/lucene/util/bkd/HeapPointReader.java b/lucene/core/src/java/org/apache/lucene/util/bkd/HeapPointReader.javaindex 7beb8df6e14..bc37f5b780f 100644--- a/lucene/core/src/java/org/apache/lucene/util/bkd/HeapPointReader.java+++ b/lucene/core/src/java/org/apache/lucene/util/bkd/HeapPointReader.java@@ -37,7 +37,12 @@ public final class HeapPointReader implements PointReader {curRead = start-1;this.end = end;this.packedBytesLength = packedBytesLength;- this.pointValue = new HeapPointValue(block, packedBytesLength);+ if (start < end) {+ this.pointValue = new HeapPointValue(block, packedBytesLength);+ } else {+ //no values+ this.pointValue = new HeapPointValue(block, 0);+ }}@Overridediff --git a/lucene/core/src/java/org/apache/lucene/util/bkd/HeapPointWriter.java b/lucene/core/src/java/org/apache/lucene/util/bkd/HeapPointWriter.javaindex 8915b0c27e3..83978510bbb 100644--- a/lucene/core/src/java/org/apache/lucene/util/bkd/HeapPointWriter.java+++ b/lucene/core/src/java/org/apache/lucene/util/bkd/HeapPointWriter.java@@ -41,7 +41,12 @@ public final class HeapPointWriter implements PointWriter {this.size = size;this.packedBytesLength = packedBytesLength;this.scratch = new byte[packedBytesLength];- offlinePointValue = new HeapPointReader.HeapPointValue(block, packedBytesLength);+ if (size > 0) {+ offlinePointValue = new HeapPointReader.HeapPointValue(block, packedBytesLength);+ } else {+ //no values+ offlinePointValue = new HeapPointReader.HeapPointValue(block, 0);+ }}/** Returns a reference, in <code>result</code>, to the byte[] slice holding this value */