Skip to content

Commit

Permalink
[CORE] Support alpha/beta releases in version parsing too
Browse files Browse the repository at this point in the history
Pull Request elastic#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 elastic#7055
  • Loading branch information
s1monw committed Jul 28, 2014
1 parent 2cd2fe8 commit 6fdf06d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/main/java/org/elasticsearch/common/lucene/Lucene.java
Expand Up @@ -43,8 +43,6 @@
import java.io.IOException;
import java.util.Locale;

import static org.elasticsearch.common.lucene.search.NoopCollector.NOOP_COLLECTOR;

/**
*
*/
Expand Down Expand Up @@ -422,7 +420,7 @@ public static Version parse(String toParse, Version defaultValue) {
} catch (IllegalArgumentException e) {
final String parsedMatchVersion = toParse
.toUpperCase(Locale.ROOT)
.replaceFirst("^(\\d+)\\.(\\d+).(\\d+)$", "LUCENE_$1_$2");
.replaceFirst("^(\\d+)\\.(\\d+)(.(\\d+))+$", "LUCENE_$1_$2");
return Version.valueOf(parsedMatchVersion);
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/test/java/org/elasticsearch/VersionTests.java
Expand Up @@ -119,6 +119,9 @@ public void parseLenient() {
.replaceFirst("^LUCENE_(\\d+)_(\\d+)$", "$1.$2");
if (randomBoolean()) {
string = string + "." + randomIntBetween(0, 100);
if (randomBoolean()) {
string = string + "." + randomIntBetween(0, 100);
}
}
assertThat(luceneVersion, Matchers.equalTo(Lucene.parseVersionLenient(string, null)));
}
Expand Down

0 comments on commit 6fdf06d

Please sign in to comment.