From 5ff3488c807372ff68761cd0aee52ee703431bb7 Mon Sep 17 00:00:00 2001 From: Dmitry Telegin Date: Fri, 28 Jun 2024 18:50:20 +0100 Subject: [PATCH] Incorrect version comparison in ModelVersion Closes #30935 Signed-off-by: Dmitry Telegin --- .../src/main/java/org/keycloak/migration/ModelVersion.java | 2 +- .../{MigrationVersionTest.java => ModelVersionTest.java} | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) rename server-spi-private/src/test/java/org/keycloak/models/{MigrationVersionTest.java => ModelVersionTest.java} (92%) diff --git a/server-spi-private/src/main/java/org/keycloak/migration/ModelVersion.java b/server-spi-private/src/main/java/org/keycloak/migration/ModelVersion.java index 69d415f401..1eaa1ba0af 100755 --- a/server-spi-private/src/main/java/org/keycloak/migration/ModelVersion.java +++ b/server-spi-private/src/main/java/org/keycloak/migration/ModelVersion.java @@ -94,7 +94,7 @@ public class ModelVersion { if (micro < version.micro) { return true; - } else if (minor > version.minor) { + } else if (micro > version.micro) { return false; } diff --git a/server-spi-private/src/test/java/org/keycloak/models/MigrationVersionTest.java b/server-spi-private/src/test/java/org/keycloak/models/ModelVersionTest.java similarity index 92% rename from server-spi-private/src/test/java/org/keycloak/models/MigrationVersionTest.java rename to server-spi-private/src/test/java/org/keycloak/models/ModelVersionTest.java index 39fa8da85e..5941be6aef 100755 --- a/server-spi-private/src/test/java/org/keycloak/models/MigrationVersionTest.java +++ b/server-spi-private/src/test/java/org/keycloak/models/ModelVersionTest.java @@ -25,7 +25,7 @@ import org.keycloak.migration.ModelVersion; * @author Bill Burke * @version $Revision: 1 $ */ -public class MigrationVersionTest { +public class ModelVersionTest { @Test public void testVersion() { @@ -93,6 +93,11 @@ public class MigrationVersionTest { Assert.assertEquals(0, versionProduct.getMinor()); Assert.assertEquals(0, versionProduct.getMicro()); Assert.assertNull(versionProduct.getQualifier()); + + ModelVersion version_24_0_0 = new ModelVersion("24.0.0"); + ModelVersion version_24_0_4_0_SNAPSHOT = new ModelVersion("24.0.4.0-SNAPSHOT"); + Assert.assertTrue(version_24_0_0.lessThan(version_24_0_4_0_SNAPSHOT)); + Assert.assertFalse(version_24_0_4_0_SNAPSHOT.lessThan(version_24_0_0)); } }