Apache Lucene open-source search software
LUCENE-6246: fix missed checks on PostingsEnum.POSITIONS
Ryan Ernstd59b1e944a3b
diff --git a/lucene/codecs/src/java/org/apache/lucene/codecs/memory/DirectPostingsFormat.java b/lucene/codecs/src/java/org/apache/lucene/codecs/memory/DirectPostingsFormat.javaindex 47902067127..4d73eaa3e1b 100644--- a/lucene/codecs/src/java/org/apache/lucene/codecs/memory/DirectPostingsFormat.java+++ b/lucene/codecs/src/java/org/apache/lucene/codecs/memory/DirectPostingsFormat.java@@ -860,7 +860,7 @@ public final class DirectPostingsFormat extends PostingsFormat {// TODO: implement reuse// it's hairy!- if ((flags & PostingsEnum.POSITIONS) >= PostingsEnum.POSITIONS) {+ if (PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS)) {if (!hasPos) {return null;}@@ -1454,7 +1454,7 @@ public final class DirectPostingsFormat extends PostingsFormat {public PostingsEnum postings(Bits liveDocs, PostingsEnum reuse, int flags) {// TODO: implement reuse// it's hairy!- if ((flags & PostingsEnum.POSITIONS) >= PostingsEnum.POSITIONS) {+ if (PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS)) {if (!hasPos) {return null;}diff --git a/lucene/codecs/src/java/org/apache/lucene/codecs/memory/MemoryPostingsFormat.java b/lucene/codecs/src/java/org/apache/lucene/codecs/memory/MemoryPostingsFormat.javaindex 7625f5e5f70..ecc70cdfbf7 100644--- a/lucene/codecs/src/java/org/apache/lucene/codecs/memory/MemoryPostingsFormat.java+++ b/lucene/codecs/src/java/org/apache/lucene/codecs/memory/MemoryPostingsFormat.java@@ -829,7 +829,7 @@ public final class MemoryPostingsFormat extends PostingsFormat {@Overridepublic PostingsEnum postings(Bits liveDocs, PostingsEnum reuse, int flags) {- if ((flags & PostingsEnum.POSITIONS) >= PostingsEnum.POSITIONS) {+ if (PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS)) {if (field.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) < 0) {return null;}diff --git a/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingTermVectorsReader.java b/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingTermVectorsReader.javaindex 4f986aa74f7..7f2e0f7c2d0 100644--- a/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingTermVectorsReader.java+++ b/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingTermVectorsReader.java@@ -937,7 +937,7 @@ public final class CompressingTermVectorsReader extends TermVectorsReader implem@Overridepublic final PostingsEnum postings(Bits liveDocs, PostingsEnum reuse, int flags) throws IOException {- if ((flags & PostingsEnum.POSITIONS) >= PostingsEnum.POSITIONS) {+ if (PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS)) {if (positions == null && startOffsets == null)return null;}diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50PostingsReader.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50PostingsReader.javaindex 6a710a6e69b..4fe53a998bd 100644--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50PostingsReader.java+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50PostingsReader.java@@ -194,7 +194,7 @@ public final class Lucene50PostingsReader extends PostingsReaderBase {@Overridepublic PostingsEnum postings(FieldInfo fieldInfo, BlockTermState termState, Bits liveDocs, PostingsEnum reuse, int flags) throws IOException {- if ((flags & PostingsEnum.POSITIONS) < PostingsEnum.POSITIONS) {+ if (PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS) == false) {BlockDocsEnum docsEnum;if (reuse instanceof BlockDocsEnum) {docsEnum = (BlockDocsEnum) reuse;diff --git a/lucene/core/src/java/org/apache/lucene/index/FreqProxFields.java b/lucene/core/src/java/org/apache/lucene/index/FreqProxFields.javaindex 07887c2692e..2ffbbb19d99 100644--- a/lucene/core/src/java/org/apache/lucene/index/FreqProxFields.java+++ b/lucene/core/src/java/org/apache/lucene/index/FreqProxFields.java@@ -235,7 +235,7 @@ class FreqProxFields extends Fields {throw new IllegalArgumentException("liveDocs must be null");}- if ((flags & PostingsEnum.POSITIONS) >= PostingsEnum.POSITIONS) {+ if (PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS)) {FreqProxPostingsEnum posEnum;if (!terms.hasProx) {