LUCENE-7383: Fix 'dimensionNumBytes' validation

This commit is contained in:
Martijn van Groningen 2016-07-22 16:26:05 +02:00
parent 85a585c516
commit 9b85f68278
3 changed files with 5 additions and 3 deletions

View File

@ -76,6 +76,9 @@ Bug Fixes
wrong default AttributeFactory for new Tokenizers.
(Terry Smith, Uwe Schindler)
* LUCENE-7389: Fix FieldType.setDimensions(...) validation for the dimensionNumBytes
parameter. (Martijn van Groningen)
Improvements
* LUCENE-7323: Compound file writing now verifies the incoming

View File

@ -374,7 +374,7 @@ public class FieldType implements IndexableFieldType {
if (dimensionNumBytes < 0) {
throw new IllegalArgumentException("dimensionNumBytes must be >= 0; got " + dimensionNumBytes);
}
if (dimensionCount > PointValues.MAX_NUM_BYTES) {
if (dimensionNumBytes > PointValues.MAX_NUM_BYTES) {
throw new IllegalArgumentException("dimensionNumBytes must be <= " + PointValues.MAX_NUM_BYTES + "; got " + dimensionNumBytes);
}
if (dimensionCount == 0) {

View File

@ -362,9 +362,8 @@ public class TestPointValues extends LuceneTestCase {
IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
IndexWriter w = new IndexWriter(dir, iwc);
Document doc = new Document();
doc.add(new BinaryPoint("dim", new byte[PointValues.MAX_NUM_BYTES+1]));
expectThrows(IllegalArgumentException.class, () -> {
w.addDocument(doc);
doc.add(new BinaryPoint("dim", new byte[PointValues.MAX_NUM_BYTES+1]));
});
Document doc2 = new Document();