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 #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
  • Loading branch information
s1monw committed Jul 28, 2014
1 parent d2493ea commit bf7f97d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 1 addition & 3 deletions src/main/java/org/elasticsearch/common/lucene/Lucene.java
Expand Up @@ -44,8 +44,6 @@
import java.io.IOException;
import java.util.Locale;

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

/**
*
*/
Expand Down Expand Up @@ -556,7 +554,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
5 changes: 4 additions & 1 deletion src/test/java/org/elasticsearch/VersionTests.java
Expand Up @@ -128,9 +128,12 @@ 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)));
}
}

}
}

0 comments on commit bf7f97d

Please sign in to comment.