Skip to content

Commit

Permalink
TransportVersionUtils#randomVersionBetween does not work with version…
Browse files Browse the repository at this point in the history
… extensions (106119)

Fixes elastic#106119
  • Loading branch information
alexey-ivanov-es committed Nov 4, 2024
1 parent de9851a commit d4ab0db
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@ public static TransportVersion randomVersionBetween(
}
int maxVersionIndex = ALL_VERSIONS.size() - 1;
if (maxVersion != null) {
maxVersionIndex = Collections.binarySearch(ALL_VERSIONS, maxVersion);
// current version might be serverless one and therefore might be after the last version in ALL_VERSIONS
if (maxVersion.after(ALL_VERSIONS.getLast()) && maxVersion.onOrBefore(TransportVersion.current())) {
maxVersionIndex = ALL_VERSIONS.size() - 1;
} else {
maxVersionIndex = Collections.binarySearch(ALL_VERSIONS, maxVersion);
}
}
if (minVersionIndex < 0) {
throw new IllegalArgumentException("minVersion [" + minVersion + "] does not exist.");
Expand Down

0 comments on commit d4ab0db

Please sign in to comment.