From 157c945bfb543a7e61fb388d92ff52aa676d348b Mon Sep 17 00:00:00 2001 From: Nikolaj Volgushev Date: Mon, 20 Nov 2023 09:58:28 +0100 Subject: [PATCH] Assert --- .../license/internal/TrialLicenseVersion.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/internal/TrialLicenseVersion.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/internal/TrialLicenseVersion.java index 0bc888a0cc658..b055de2e8ae97 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/internal/TrialLicenseVersion.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/internal/TrialLicenseVersion.java @@ -82,12 +82,17 @@ int asInt() { } public boolean ableToStartNewTrial() { - // It should never be possible for trialVersion to be greater than CURRENT... - if (asInt() < TRIAL_VERSION_CUTOVER) { - int sinceMajorVersion = asInt() / 1_000_000; // integer division is intentional + assert trialVersion <= CURRENT.trialVersion + : "trial version [" + + trialVersion + + "] cannot be greater than CURRENT [" + + CURRENT.trialVersion + + "] which represents the maximum possible value"; + if (trialVersion < TRIAL_VERSION_CUTOVER) { + int sinceMajorVersion = trialVersion / 1_000_000; // integer division is intentional return sinceMajorVersion < TRIAL_VERSION_CUTOVER_MAJOR; } - return trialVersion < CURRENT.asInt(); + return trialVersion != CURRENT.trialVersion; } @Override