[CORE] Support alpha/beta releases in version parsing too
Pull Request #7055 fixed Version parsing for bugfix releases causing problems with minor version in segments files. Even though we never release anything with lucene in alpha / beta status this commit fixes lenient parsing for these cases. Relates to #7055
This commit is contained in:
parent
d2493ea48a
commit
bf7f97d22f
|
@ -44,8 +44,6 @@ import org.elasticsearch.index.fielddata.IndexFieldData;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import static org.elasticsearch.common.lucene.search.NoopCollector.NOOP_COLLECTOR;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -556,7 +554,7 @@ public class Lucene {
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
final String parsedMatchVersion = toParse
|
final String parsedMatchVersion = toParse
|
||||||
.toUpperCase(Locale.ROOT)
|
.toUpperCase(Locale.ROOT)
|
||||||
.replaceFirst("^(\\d+)\\.(\\d+).(\\d+)$", "LUCENE_$1_$2");
|
.replaceFirst("^(\\d+)\\.(\\d+)(.(\\d+))+$", "LUCENE_$1_$2");
|
||||||
return Version.valueOf(parsedMatchVersion);
|
return Version.valueOf(parsedMatchVersion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,9 +128,12 @@ public class VersionTests extends ElasticsearchTestCase {
|
||||||
.replaceFirst("^LUCENE_(\\d+)_(\\d+)$", "$1.$2");
|
.replaceFirst("^LUCENE_(\\d+)_(\\d+)$", "$1.$2");
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
string = string + "." + randomIntBetween(0, 100);
|
string = string + "." + randomIntBetween(0, 100);
|
||||||
|
if (randomBoolean()) {
|
||||||
|
string = string + "." + randomIntBetween(0, 100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
assertThat(luceneVersion, Matchers.equalTo(Lucene.parseVersionLenient(string, null)));
|
assertThat(luceneVersion, Matchers.equalTo(Lucene.parseVersionLenient(string, null)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue