Skip to content

Commit 1a3cd38

Browse files
Update Oracle JDK URL calculation
1 parent 1f2faad commit 1a3cd38

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

__tests__/distributors/oracle-installer.test.ts

+4-7
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('findPackageForDownload', () => {
2525
[
2626
'20',
2727
'20',
28-
'https://download.oracle.com/java/20/latest/jdk-20_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}'
28+
'https://download.oracle.com/java/20/archive/jdk-20_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}'
2929
],
3030
[
3131
'20.0.1',
@@ -35,15 +35,15 @@ describe('findPackageForDownload', () => {
3535
[
3636
'17',
3737
'17',
38-
'https://download.oracle.com/java/17/latest/jdk-17_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}'
38+
'https://download.oracle.com/java/17/archive/jdk-17_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}'
3939
],
4040
[
4141
'17.0.1',
4242
'17.0.1',
4343
'https://download.oracle.com/java/17/archive/jdk-17.0.1_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}'
4444
]
4545
])('version is %s -> %s', async (input, expectedVersion, expectedUrl) => {
46-
/* Needed only for this particular test because /latest/ urls tend to change */
46+
/* Needed only for this particular test because some urls might change */
4747
spyHttpClient = jest.spyOn(HttpClient.prototype, 'head');
4848
spyHttpClient.mockReturnValue(
4949
Promise.resolve({
@@ -89,7 +89,7 @@ describe('findPackageForDownload', () => {
8989
}
9090
const archiveType = getDownloadArchiveExtension();
9191
const result = await distro['findPackageForDownload'](version);
92-
const expectedUrl = `https://download.oracle.com/java/17/latest/jdk-17_${osType}-${distroArch}_bin.${archiveType}`;
92+
const expectedUrl = `https://download.oracle.com/java/17/archive/jdk-17_${osType}-${distroArch}_bin.${archiveType}`;
9393

9494
expect(result.url).toBe(expectedUrl);
9595
}
@@ -102,8 +102,5 @@ describe('findPackageForDownload', () => {
102102
await expect(distribution['findPackageForDownload']('11')).rejects.toThrow(
103103
/Oracle JDK is only supported for JDK 17 and later/
104104
);
105-
await expect(distribution['findPackageForDownload']('18')).rejects.toThrow(
106-
/Could not find Oracle JDK for SemVer */
107-
);
108105
});
109106
});

src/distributions/oracle/installer.ts

+2-9
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,8 @@ export class OracleDistribution extends JavaBase {
6565

6666
const platform = this.getPlatform();
6767
const extension = getDownloadArchiveExtension();
68-
let major;
69-
let fileUrl;
70-
if (range.includes('.')) {
71-
major = range.split('.')[0];
72-
fileUrl = `${ORACLE_DL_BASE}/${major}/archive/jdk-${range}_${platform}-${arch}_bin.${extension}`;
73-
} else {
74-
major = range;
75-
fileUrl = `${ORACLE_DL_BASE}/${range}/latest/jdk-${range}_${platform}-${arch}_bin.${extension}`;
76-
}
68+
const major = range.includes('.') ? range.split('.')[0] : range;
69+
const fileUrl = `${ORACLE_DL_BASE}/${major}/archive/jdk-${range}_${platform}-${arch}_bin.${extension}`;
7770

7871
if (parseInt(major) < 17) {
7972
throw new Error('Oracle JDK is only supported for JDK 17 and later');

0 commit comments

Comments
 (0)