You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sd...@apache.org on 2022/06/09 12:37:24 UTC
[ignite-3] branch ignite-3.0.0-alpha5 updated: IGNITE-17144 Fix parsing of alpha versions of Ignite (#873)
This is an automated email from the ASF dual-hosted git repository.
sdanilov pushed a commit to branch ignite-3.0.0-alpha5
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/ignite-3.0.0-alpha5 by this push:
new ab60e7675 IGNITE-17144 Fix parsing of alpha versions of Ignite (#873)
ab60e7675 is described below
commit ab60e76755558a70efddf6f88742e2b309429b8e
Author: Alexander Polovtcev <al...@gmail.com>
AuthorDate: Thu Jun 9 15:28:27 2022 +0300
IGNITE-17144 Fix parsing of alpha versions of Ignite (#873)
---
.../internal/properties/IgniteProductVersion.java | 39 ++++++++++++++++++----
.../properties/IgniteProductVersionTest.java | 13 ++++++++
2 files changed, 46 insertions(+), 6 deletions(-)
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/properties/IgniteProductVersion.java b/modules/core/src/main/java/org/apache/ignite/internal/properties/IgniteProductVersion.java
index 5ca3edac3..b4ec5027b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/properties/IgniteProductVersion.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/properties/IgniteProductVersion.java
@@ -22,13 +22,14 @@ import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.ignite.internal.util.StringUtils;
+import org.jetbrains.annotations.Nullable;
/**
* Class representing an Ignite version.
*/
public class IgniteProductVersion implements Serializable {
private static final Pattern VERSION_PATTERN =
- Pattern.compile("(?<major>\\d+)\\.(?<minor>\\d+)\\.(?<maintenance>\\d+)(?<snapshot>-SNAPSHOT)?");
+ Pattern.compile("(?<major>\\d+)\\.(?<minor>\\d+)\\.(?<maintenance>\\d+)((?<snapshot>-SNAPSHOT)|-(?<alpha>alpha\\d+))?");
/**
* Version of the current node.
@@ -47,11 +48,16 @@ public class IgniteProductVersion implements Serializable {
/** Flag indicating if this is a snapshot release. */
private final boolean isSnapshot;
- private IgniteProductVersion(byte major, byte minor, byte maintenance, boolean isSnapshot) {
+ /** Alpha version part or an empty string if this is not an alpha release. */
+ // TODO: IGNITE-17146 Fix and add support for beta and other releases
+ private final String alphaVersion;
+
+ private IgniteProductVersion(byte major, byte minor, byte maintenance, boolean isSnapshot, @Nullable String alphaVersion) {
this.major = major;
this.minor = minor;
this.maintenance = maintenance;
this.isSnapshot = isSnapshot;
+ this.alphaVersion = alphaVersion == null ? "" : alphaVersion;
}
/**
@@ -76,26 +82,46 @@ public class IgniteProductVersion implements Serializable {
Byte.parseByte(matcher.group("major")),
Byte.parseByte(matcher.group("minor")),
Byte.parseByte(matcher.group("maintenance")),
- matcher.group("snapshot") != null
+ matcher.group("snapshot") != null,
+ matcher.group("alpha")
);
}
+ /**
+ * Returns the major version number.
+ */
public byte major() {
return major;
}
+ /**
+ * Returns the minor version number.
+ */
public byte minor() {
return minor;
}
+ /**
+ * Returns the maintenance version number.
+ */
public byte maintenance() {
return maintenance;
}
+ /**
+ * Returns {@code true} if this is a snapshot release, {@code false} otherwise.
+ */
public boolean snapshot() {
return isSnapshot;
}
+ /**
+ * Returns the alpha version of this release or an empty string if this is not an alpha release.
+ */
+ public String alphaVersion() {
+ return alphaVersion;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) {
@@ -105,18 +131,19 @@ public class IgniteProductVersion implements Serializable {
return false;
}
IgniteProductVersion that = (IgniteProductVersion) o;
- return major == that.major && minor == that.minor && maintenance == that.maintenance && isSnapshot == that.isSnapshot;
+ return major == that.major && minor == that.minor && maintenance == that.maintenance && isSnapshot == that.isSnapshot
+ && alphaVersion.equals(that.alphaVersion);
}
@Override
public int hashCode() {
- return Objects.hash(major, minor, maintenance, isSnapshot);
+ return Objects.hash(major, minor, maintenance, isSnapshot, alphaVersion);
}
@Override
public String toString() {
String version = String.join(".", String.valueOf(major), String.valueOf(minor), String.valueOf(maintenance));
- return version + (isSnapshot ? "-SNAPSHOT" : "");
+ return version + (alphaVersion.isEmpty() ? "" : "-" + alphaVersion) + (isSnapshot ? "-SNAPSHOT" : "");
}
}
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/properties/IgniteProductVersionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/properties/IgniteProductVersionTest.java
index 9524e18d1..8af28dc1f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/properties/IgniteProductVersionTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/properties/IgniteProductVersionTest.java
@@ -18,6 +18,7 @@
package org.apache.ignite.internal.properties;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.emptyString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -36,6 +37,7 @@ public class IgniteProductVersionTest {
assertThat(version.minor(), is((byte) 0));
assertThat(version.maintenance(), is((byte) 0));
assertThat(version.snapshot(), is(true));
+ assertThat(version.alphaVersion(), is(emptyString()));
assertThat(version.toString(), is(equalTo("3.0.0-SNAPSHOT")));
version = IgniteProductVersion.fromString("1.2.3");
@@ -44,7 +46,17 @@ public class IgniteProductVersionTest {
assertThat(version.minor(), is((byte) 2));
assertThat(version.maintenance(), is((byte) 3));
assertThat(version.snapshot(), is(false));
+ assertThat(version.alphaVersion(), is(emptyString()));
assertThat(version.toString(), is(equalTo("1.2.3")));
+
+ version = IgniteProductVersion.fromString("3.0.0-alpha22");
+
+ assertThat(version.major(), is((byte) 3));
+ assertThat(version.minor(), is((byte) 0));
+ assertThat(version.maintenance(), is((byte) 0));
+ assertThat(version.snapshot(), is(false));
+ assertThat(version.alphaVersion(), is("alpha22"));
+ assertThat(version.toString(), is(equalTo("3.0.0-alpha22")));
}
@Test
@@ -54,5 +66,6 @@ public class IgniteProductVersionTest {
assertThrows(IllegalArgumentException.class, () -> IgniteProductVersion.fromString("a.b.c"));
assertThrows(IllegalArgumentException.class, () -> IgniteProductVersion.fromString("1.2.3-"));
assertThrows(IllegalArgumentException.class, () -> IgniteProductVersion.fromString("1.2.3-SSDAD"));
+ assertThrows(IllegalArgumentException.class, () -> IgniteProductVersion.fromString("1.2.3-SNAPSHOT-alpha123"));
}
}