Skip to content

Commit e745c1e

Browse files
authored
IGNITE-27354 Fix deployment unit version (#7236)
1 parent 563a4a7 commit e745c1e

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

modules/api/src/main/java/org/apache/ignite/deployment/version/UnitVersion.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@ class UnitVersion implements Version {
3535
);
3636

3737
/** Major version number. */
38-
private final byte major;
38+
private final int major;
3939

4040
/** Minor version number. */
41-
private final byte minor;
41+
private final int minor;
4242

4343
/** Maintenance version number. */
44-
private final byte maintenance;
44+
private final int maintenance;
4545

4646
/** Patch version number. */
4747
@Nullable
48-
private final Byte patch;
48+
private final Integer patch;
4949

5050
/** Pre-release version. */
5151
@Nullable
@@ -58,7 +58,7 @@ class UnitVersion implements Version {
5858
* @param minor Minor part of version.
5959
* @param maintenance Maintenance part of version.
6060
*/
61-
UnitVersion(byte major, byte minor, byte maintenance, @Nullable Byte patch, @Nullable String preRelease) {
61+
UnitVersion(int major, int minor, int maintenance, @Nullable Integer patch, @Nullable String preRelease) {
6262
this.major = major;
6363
this.minor = minor;
6464
this.maintenance = maintenance;
@@ -93,10 +93,10 @@ public static UnitVersion parse(String rawVersion) {
9393
String preRelease = matcher.group("preRelease");
9494

9595
return new UnitVersion(
96-
Byte.parseByte(matcher.group("major")),
97-
nullOrBlank(minor) ? 0 : Byte.parseByte(minor),
98-
nullOrBlank(maintenance) ? 0 : Byte.parseByte(maintenance),
99-
nullOrBlank(patch) ? null : Byte.parseByte(patch),
96+
Integer.parseUnsignedInt(matcher.group("major")),
97+
nullOrBlank(minor) ? 0 : Integer.parseUnsignedInt(minor),
98+
nullOrBlank(maintenance) ? 0 : Integer.parseUnsignedInt(maintenance),
99+
nullOrBlank(patch) ? null : Integer.parseUnsignedInt(patch),
100100
nullOrBlank(preRelease) ? null : preRelease
101101
);
102102
} catch (NumberFormatException e) {
@@ -118,17 +118,17 @@ public int compareTo(Version o) {
118118
int res;
119119

120120
// Compare major, minor, maintenance
121-
res = Byte.compare(major, other.major);
121+
res = Integer.compare(major, other.major);
122122
if (res != 0) {
123123
return res;
124124
}
125125

126-
res = Byte.compare(minor, other.minor);
126+
res = Integer.compare(minor, other.minor);
127127
if (res != 0) {
128128
return res;
129129
}
130130

131-
res = Byte.compare(maintenance, other.maintenance);
131+
res = Integer.compare(maintenance, other.maintenance);
132132
if (res != 0) {
133133
return res;
134134
}
@@ -144,9 +144,9 @@ public int compareTo(Version o) {
144144
return res;
145145
}
146146

147-
private static int compareNullable(@Nullable Byte a, @Nullable Byte b) {
147+
private static int compareNullable(@Nullable Integer a, @Nullable Integer b) {
148148
if (a != null && b != null) {
149-
return Byte.compare(a, b);
149+
return Integer.compare(a, b);
150150
} else if (a != null) {
151151
return 1;
152152
} else if (b != null) {
@@ -156,7 +156,7 @@ private static int compareNullable(@Nullable Byte a, @Nullable Byte b) {
156156
}
157157

158158
@Nullable
159-
private static Byte preReleaseOrder(@Nullable String preRelease) {
159+
private static Integer preReleaseOrder(@Nullable String preRelease) {
160160
if (preRelease == null) {
161161
return null;
162162
}

modules/api/src/test/java/org/apache/ignite/deployment/version/VersionTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ private static Stream<Arguments> validVersions() {
3737
return Stream.of(
3838
arguments("1.1.0", version(1, 1, 0, null, null)),
3939
arguments("1.1.01", version(1, 1, 1, null, null)),
40+
arguments("1000.10000.100000", version(1000, 10000, 100000, null, null)),
4041
arguments("1.1", version(1, 1, 0, null, null)),
4142
arguments("1", version(1, 0, 0, null, null)),
4243
arguments("1.1.1.1", version(1, 1, 1, 1, null)),
@@ -52,15 +53,14 @@ public void testParseCorrect(String versionString, Version expected) {
5253
}
5354

5455
@ParameterizedTest
55-
@ValueSource(strings = {"", "version", "1.", "65536", "1.1f"})
56+
@ValueSource(strings = {"", "version", "1.", "-1", "1.1f"})
5657
public void testParseErrors(String versionString) {
5758
assertThrows(VersionParseException.class, () -> Version.parseVersion(versionString));
5859
}
5960

6061
private static UnitVersion version(
6162
int major, int minor, int maintenance, @Nullable Integer patch, @Nullable String preRelease
6263
) {
63-
Byte patchByte = patch != null ? patch.byteValue() : null;
64-
return new UnitVersion((byte) major, (byte) minor, (byte) maintenance, patchByte, preRelease);
64+
return new UnitVersion(major, minor, maintenance, patch, preRelease);
6565
}
6666
}

0 commit comments

Comments
 (0)