Prefer Zulu 4-segment hotfix builds when resolving version ranges (#1278)

Azul reports hotfix releases like 25.0.4.1 as java_version=[25,0,4,1]
with openjdk_build_number=1 (SDKMAN '25.0.4+1.1'). Sorting candidates via
semver.compareBuild ranked 25.0.4+7 above 25.0.4+1.1, so ranges such as
'25' resolved to the older build. Compare java_version, build number and
distro_version numerically instead.

Fixes: #1275

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Bruno Borges
2026-10-02 00:07:25 -04:00
committed by GitHub
parent a78ec39f12
commit 74920aab4a
4 changed files with 117 additions and 26 deletions
@@ -334,6 +334,69 @@ describe('findPackageForDownload', () => {
);
});
describe('hotfix builds with a 4-segment java_version', () => {
// Mirrors the Azul Metadata API: 25.0.4.1 hotfix is reported as
// java_version=[25,0,4,1], openjdk_build_number=1 (SDKMAN '25.0.4+1.1').
const hotfixManifest = [
{
package_uuid: 'uuid-25.0.4+7',
name: 'zulu25.36.15-ca-jdk25.0.4-linux_x64.tar.gz',
download_url:
'https://cdn.azul.com/zulu/bin/zulu25.36.15-ca-jdk25.0.4-linux_x64.tar.gz',
java_version: [25, 0, 4],
openjdk_build_number: 7,
distro_version: [25, 36, 15, 0],
latest: false,
availability_type: 'ca'
},
{
package_uuid: 'uuid-25.0.4+1.1',
name: 'zulu25.36.205-ca-jdk25.0.4.1-linux_x64.tar.gz',
download_url:
'https://cdn.azul.com/zulu/bin/zulu25.36.205-ca-jdk25.0.4.1-linux_x64.tar.gz',
java_version: [25, 0, 4, 1],
openjdk_build_number: 1,
distro_version: [25, 36, 205, 0],
latest: true,
availability_type: 'ca'
},
{
package_uuid: 'uuid-25.0.3+9',
name: 'zulu25.34.17-ca-jdk25.0.3-linux_x64.tar.gz',
download_url:
'https://cdn.azul.com/zulu/bin/zulu25.34.17-ca-jdk25.0.3-linux_x64.tar.gz',
java_version: [25, 0, 3],
openjdk_build_number: 9,
distro_version: [25, 34, 17, 0],
latest: false,
availability_type: 'ca'
}
] as IZuluVersions[];
it.each([
['25.0.4+1.1', '25.0.4+1.1', 'uuid-25.0.4+1.1'],
['25', '25.0.4+1.1', 'uuid-25.0.4+1.1'],
['25.0.4', '25.0.4+1.1', 'uuid-25.0.4+1.1'],
['25.0.4+7', '25.0.4+7', 'uuid-25.0.4+7'],
['25.0.3', '25.0.3+9', 'uuid-25.0.3+9']
])('version is %s -> %s', async (input, expected, uuid) => {
const distribution = new ZuluDistribution({
version: input,
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});
distribution['getAvailableVersions'] = async () => hotfixManifest;
const result = await distribution['findPackageForDownload'](
distribution['version']
);
expect(result.version).toBe(expected);
expect(result.url).toBe(
hotfixManifest.find(item => item.package_uuid === uuid)!.download_url
);
});
});
it('should throw an error', async () => {
const distribution = new ZuluDistribution({
version: '18',