Index: lucene/CHANGES.txt =================================================================== --- lucene/CHANGES.txt (revision 1190246) +++ lucene/CHANGES.txt (working copy) @@ -79,6 +79,11 @@ * LUCENE-2633: PackedInts Packed32 and Packed64 did not support internal structures larger than 256MB (Toke Eskildsen via Mike McCandless) +* LUCENE-3540: LUCENE-3255 dropped support for pre-1.9 indexes, but the + IndexFormatTooOldException code was backported from trunk and had the wrong + message with a minimum supported version of 3.0. This leads to confusion if + somebody opens a too old index. (Uwe Schindler, Mike McCandless) + New Features * LUCENE-3448: Added FixedBitSet.and(other/DISI), andNot(other/DISI). Index: lucene/src/java/org/apache/lucene/index/FieldsReader.java =================================================================== --- lucene/src/java/org/apache/lucene/index/FieldsReader.java (revision 1190246) +++ lucene/src/java/org/apache/lucene/index/FieldsReader.java (working copy) @@ -129,7 +129,8 @@ fieldInfos = fn; cloneableFieldsStream = d.openInput(IndexFileNames.segmentFileName(segment, IndexFileNames.FIELDS_EXTENSION), readBufferSize); - cloneableIndexStream = d.openInput(IndexFileNames.segmentFileName(segment, IndexFileNames.FIELDS_INDEX_EXTENSION), readBufferSize); + final String indexStreamFN = IndexFileNames.segmentFileName(segment, IndexFileNames.FIELDS_INDEX_EXTENSION); + cloneableIndexStream = d.openInput(indexStreamFN, readBufferSize); // First version of fdx did not include a format // header, but, the first int will always be 0 in that @@ -141,8 +142,7 @@ format = firstInt; if (format > FieldsWriter.FORMAT_CURRENT) - throw new CorruptIndexException("Incompatible format version: " + format + " expected " - + FieldsWriter.FORMAT_CURRENT + " or lower"); + throw new IndexFormatTooNewException(indexStreamFN, format, 0, FieldsWriter.FORMAT_CURRENT); if (format > FieldsWriter.FORMAT) formatSize = 4; Index: lucene/src/java/org/apache/lucene/index/IndexFormatTooOldException.java =================================================================== --- lucene/src/java/org/apache/lucene/index/IndexFormatTooOldException.java (revision 1190246) +++ lucene/src/java/org/apache/lucene/index/IndexFormatTooOldException.java (working copy) @@ -25,13 +25,13 @@ public IndexFormatTooOldException(String filename, String version) { super("Format version is not supported" + (filename!=null ? (" in file '" + filename + "'") : "") + - ": " + version + ". This version of Lucene only supports indexes created with release 3.0 and later."); + ": " + version + ". This version of Lucene only supports indexes created with release 1.9 and later."); } public IndexFormatTooOldException(String filename, int version, int minVersion, int maxVersion) { super("Format version is not supported" + (filename!=null ? (" in file '" + filename + "'") : "") + ": " + version + " (needs to be between " + minVersion + " and " + maxVersion + - "). This version of Lucene only supports indexes created with release 3.0 and later."); + "). This version of Lucene only supports indexes created with release 1.9 and later."); } } Index: lucene/src/java/org/apache/lucene/index/SegmentTermEnum.java =================================================================== --- lucene/src/java/org/apache/lucene/index/SegmentTermEnum.java (revision 1190246) +++ lucene/src/java/org/apache/lucene/index/SegmentTermEnum.java (working copy) @@ -63,7 +63,7 @@ // check that it is a format we can understand if (format < TermInfosWriter.FORMAT_CURRENT) - throw new CorruptIndexException("Unknown format version:" + format + " expected " + TermInfosWriter.FORMAT_CURRENT + " or higher"); + throw new IndexFormatTooNewException(null, format, -1, TermInfosWriter.FORMAT_CURRENT); size = input.readLong(); // read the size Index: lucene/src/java/org/apache/lucene/index/TermVectorsReader.java =================================================================== --- lucene/src/java/org/apache/lucene/index/TermVectorsReader.java (revision 1190246) +++ lucene/src/java/org/apache/lucene/index/TermVectorsReader.java (working copy) @@ -79,11 +79,13 @@ try { String idxName = IndexFileNames.segmentFileName(segment, IndexFileNames.VECTORS_INDEX_EXTENSION); tvx = d.openInput(idxName, readBufferSize); - format = checkValidFormat(tvx); - tvd = d.openInput(IndexFileNames.segmentFileName(segment, IndexFileNames.VECTORS_DOCUMENTS_EXTENSION), readBufferSize); - final int tvdFormat = checkValidFormat(tvd); - tvf = d.openInput(IndexFileNames.segmentFileName(segment, IndexFileNames.VECTORS_FIELDS_EXTENSION), readBufferSize); - final int tvfFormat = checkValidFormat(tvf); + format = checkValidFormat(idxName, tvx); + String fn = IndexFileNames.segmentFileName(segment, IndexFileNames.VECTORS_DOCUMENTS_EXTENSION); + tvd = d.openInput(fn, readBufferSize); + final int tvdFormat = checkValidFormat(fn, tvd); + fn = IndexFileNames.segmentFileName(segment, IndexFileNames.VECTORS_FIELDS_EXTENSION); + tvf = d.openInput(fn, readBufferSize); + final int tvfFormat = checkValidFormat(fn, tvf); assert format == tvdFormat; assert format == tvfFormat; @@ -192,12 +194,11 @@ } } - private int checkValidFormat(IndexInput in) throws CorruptIndexException, IOException + private int checkValidFormat(String fn, IndexInput in) throws CorruptIndexException, IOException { int format = in.readInt(); if (format > FORMAT_CURRENT) { - throw new CorruptIndexException("Incompatible format version: " + format + " expected " - + FORMAT_CURRENT + " or less"); + throw new IndexFormatTooNewException(fn, format, 1, FORMAT_CURRENT); } return format; }