Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions changelog/unreleased/SOLR-18432-solrversion-prerelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
title: SolrVersion now tolerates a prerelease qualifier such as -SNAPSHOT. Package version constraints are matched ignoring the qualifier, the cluster version-compatibility warning no longer treats a prerelease as older than its release, and /api/node/system reports the correct Solr implementation version.
type: fixed
authors:
- name: David Smiley
links:
- name: SOLR-18432
url: https://issues.apache.org/jira/browse/SOLR-18432
12 changes: 10 additions & 2 deletions solr/api/src/java/org/apache/solr/client/api/util/SolrVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,20 @@ public boolean lessThanOrEqualTo(SolrVersion other) {

/**
* Returns true if this version satisfies the provided <a href="https://devhints.io/semver">SemVer
* Expression</a>
* Expression</a>. Any prerelease qualifier (e.g. "-SNAPSHOT") is ignored, unlike plain SemVer
* range semantics where a prerelease satisfies no range that doesn't name one.
*
* @param semVerExpression the expression to test
*/
public boolean satisfies(String semVerExpression) {
return version.satisfies(semVerExpression);
return version.withClearedPreRelease().satisfies(semVerExpression);
}

/**
* Returns this version with any prerelease qualifier removed, e.g. "10.1.0-SNAPSHOT" to "10.1.0"
*/
public SolrVersion withoutPrerelease() {
return new SolrVersion(version.withClearedPreRelease());
}

public int getMajorVersion() {
Expand Down
14 changes: 14 additions & 0 deletions solr/api/src/test/org/apache/solr/util/TestSolrVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,18 @@ public void testSatisfies() {
assertFalse(SOLR_9_0_1.satisfies("8.x"));
assertTrue(SOLR_9_0_1.satisfies("8 - 9"));
}

public void testPrereleaseIgnoredBySatisfies() {
SolrVersion snapshot = SolrVersion.valueOf("10.1.0-SNAPSHOT");
assertTrue(snapshot.satisfies(">=9.0.0"));
assertTrue(snapshot.satisfies("10.x"));
assertTrue(snapshot.satisfies("~10.1"));
assertFalse(snapshot.satisfies("<10.1"));
Comment thread
janhoy marked this conversation as resolved.
Resolved
}

public void testWithoutPrerelease() {
SolrVersion snapshot = SolrVersion.valueOf("10.1.0-SNAPSHOT");
assertTrue(snapshot.lessThan(SolrVersion.valueOf("10.1.0")));
assertEquals(SolrVersion.valueOf("10.1.0"), snapshot.withoutPrerelease());
}
}
2 changes: 1 addition & 1 deletion solr/core/src/java/org/apache/solr/cloud/ZkController.java
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ private void checkClusterVersionCompatibility() throws InterruptedException, Kee
SolrVersion ourVersion = SolrVersion.LATEST;
SolrVersion clusterVersion = lowestVersion.get();

if (ourVersion.lessThan(clusterVersion)) {
if (ourVersion.withoutPrerelease().lessThan(clusterVersion.withoutPrerelease())) {
log.warn(
"Our Solr version {} is older than cluster version {}", ourVersion, clusterVersion);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,7 @@ public NodeSystemResponse.Lucene getLuceneInfo() {
String implVersion = p.getImplementationVersion();
// non-null mostly for testing
info.solrSpecVersion = specVersion == null ? SolrVersion.LATEST_STRING : specVersion;
info.solrImplVersion =
implVersion == null ? SolrVersion.LATEST.getPrereleaseVersion() : implVersion;
info.solrImplVersion = implVersion == null ? SolrVersion.LATEST_STRING : implVersion;

info.luceneSpecVersion = Version.LATEST.toString();
info.luceneImplVersion = Version.getPackageImplementationVersion();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void testGetNodeSystemInfo() {
Assert.assertEquals(h.getCoreContainer().getCoreRootDirectory().toString(), info.coreRoot);
Assert.assertNotNull(info.lucene);
Assert.assertNotNull(info.lucene.solrImplVersion);
Assert.assertEquals(info.lucene.solrImplVersion, SolrVersion.LATEST.getPrereleaseVersion());
Assert.assertEquals(info.lucene.solrImplVersion, SolrVersion.LATEST_STRING);
Assert.assertNotNull(info.lucene.solrSpecVersion);
Assert.assertEquals(info.lucene.solrSpecVersion, SolrVersion.LATEST_STRING);
Assert.assertNotNull(info.lucene.luceneImplVersion);
Expand Down
Loading