LUCENE-4055: use version comparator

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene4055@1342221 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2012-05-24 12:23:23 +00:00
parent 4e457c6cb8
commit d00b63db82
1 changed files with 2 additions and 1 deletions

View File

@ -46,6 +46,7 @@ import org.apache.lucene.store.IndexOutput;
import org.apache.lucene.store.NoSuchDirectoryException;
import org.apache.lucene.util.CodecUtil;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.StringHelper;
import org.apache.lucene.util.ThreadInterruptedException;
/**
@ -371,7 +372,7 @@ public final class SegmentInfos implements Cloneable, Iterable<SegmentInfoPerCom
// If this segment is pre-4.x, perform a one-time
// "ugprade" to write the .si file for it:
String version = si.getVersion();
if (version == null || version.startsWith("3.")) {
if (version == null || StringHelper.getVersionComparator().compare(version, "4.0") < 0) {
String fileName = IndexFileNames.segmentFileName(si.name, "", Lucene3xSegmentInfoFormat.SI_EXTENSION);
if (!directory.fileExists(fileName)) {
upgradedSIFiles.add(write3xInfo(directory, si, IOContext.DEFAULT));