Skip to content

Commit d3e4886

Browse files
committed
improve
Signed-off-by: Attila Mészáros <[email protected]>
1 parent ec7d6e5 commit d3e4886

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/PrimaryUpdateAndCacheUtils.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,12 @@ public static int compareResourceVersions(String v1, String v2) {
460460
if (v2Length == 0) {
461461
throw new IllegalArgumentException("resource version must not be empty (2)");
462462
}
463+
if (v1.charAt(0) == '0') {
464+
throw new IllegalArgumentException("resource version (1) must not start with 0");
465+
}
466+
if (v2.charAt(0) == '0') {
467+
throw new IllegalArgumentException("resource version (2) must not start with 0");
468+
}
463469
if (v1Length > v2Length) {
464470
return 1;
465471
}

operator-framework-core/src/test/java/io/javaoperatorsdk/operator/api/reconciler/PrimaryUpdateAndCacheUtilsTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ public void compareResourceVersionsTest() {
195195
assertThrows(IllegalArgumentException.class, () -> compareResourceVersions("11", "ba"));
196196
assertThrows(IllegalArgumentException.class, () -> compareResourceVersions("", "22"));
197197
assertThrows(IllegalArgumentException.class, () -> compareResourceVersions("11", ""));
198+
assertThrows(IllegalArgumentException.class, () -> compareResourceVersions("01", "123"));
199+
assertThrows(IllegalArgumentException.class, () -> compareResourceVersions("123", "01"));
198200
}
199201

200202
// naive performance that compares the works case scenario for non parsing variant

0 commit comments

Comments
 (0)