mirror of
https://github.com/actions/setup-java.git
synced 2026-11-14 07:52:24 +00:00
Fix Oracle JDK 21 e2e and warn on archived GA fallback (#1327)
Oracle no longer serves JDK 21 under /java/21/latest/, so a major-only request falls back to the archived 21 GA build and reports version 21. The e2e check required a concrete version for floating Oracle requests, so the oracle 21 jobs failed. Move floating Oracle e2e coverage to JDK 25 and keep a single oracle 21 job that exercises the archive fallback without the concrete-version requirement. Warn when a major-only request falls back from /latest/ to the archived GA release, since that build may lack security updates. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -80,10 +80,14 @@ jobs:
|
|||||||
version: 25
|
version: 25
|
||||||
- distribution: oracle
|
- distribution: oracle
|
||||||
os: macos-15-intel
|
os: macos-15-intel
|
||||||
version: 21
|
version: 25
|
||||||
- distribution: oracle
|
- distribution: oracle
|
||||||
os: windows-latest
|
os: windows-latest
|
||||||
version: 21
|
version: 25
|
||||||
|
- distribution: oracle
|
||||||
|
os: ubuntu-latest
|
||||||
|
version: 25
|
||||||
|
# Oracle no longer publishes JDK 21 under /latest, so a major-only request resolves to the archived GA build.
|
||||||
- distribution: oracle
|
- distribution: oracle
|
||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
version: 21
|
version: 21
|
||||||
@@ -127,7 +131,7 @@ jobs:
|
|||||||
JAVA_VERSION: ${{ matrix.version }}
|
JAVA_VERSION: ${{ matrix.version }}
|
||||||
JAVA_PATH: ${{ steps.setup-java.outputs.path }}
|
JAVA_PATH: ${{ steps.setup-java.outputs.path }}
|
||||||
SETUP_JAVA_VERSION: ${{ steps.setup-java.outputs.version }}
|
SETUP_JAVA_VERSION: ${{ steps.setup-java.outputs.version }}
|
||||||
REQUIRE_CONCRETE_VERSION: ${{ (matrix.distribution == 'oracle' || matrix.distribution == 'graalvm') && !contains(matrix.version, '.') && !contains(matrix.version, '-ea') }}
|
REQUIRE_CONCRETE_VERSION: ${{ ((matrix.distribution == 'oracle' && matrix.version != 21) || matrix.distribution == 'graalvm') && !contains(matrix.version, '.') && !contains(matrix.version, '-ea') }}
|
||||||
run: bash __tests__/verify-java.sh "$JAVA_VERSION" "$JAVA_PATH" "$SETUP_JAVA_VERSION" "$REQUIRE_CONCRETE_VERSION"
|
run: bash __tests__/verify-java.sh "$JAVA_VERSION" "$JAVA_PATH" "$SETUP_JAVA_VERSION" "$REQUIRE_CONCRETE_VERSION"
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
|
|||||||
@@ -185,6 +185,19 @@ describe('findPackageForDownload', () => {
|
|||||||
expect(spyHttpClientGet).toHaveBeenCalledTimes(1);
|
expect(spyHttpClientGet).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('warns when a major-only request falls back to the archived GA release', async () => {
|
||||||
|
spyHttpClient = jest.spyOn(HttpClient.prototype, 'head');
|
||||||
|
spyHttpClient
|
||||||
|
.mockResolvedValueOnce({message: {statusCode: 404}})
|
||||||
|
.mockResolvedValueOnce({message: {statusCode: 200}});
|
||||||
|
|
||||||
|
await distribution['findPackageForDownload']('21');
|
||||||
|
|
||||||
|
expect(core.warning).toHaveBeenCalledWith(
|
||||||
|
'Oracle JDK 21 is no longer available from the latest endpoint. Falling back to its archived GA release, which may not include security updates.'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('always resolves major-only requests remotely', () => {
|
it('always resolves major-only requests remotely', () => {
|
||||||
expect(distribution['requiresRemoteResolution']()).toBe(true);
|
expect(distribution['requiresRemoteResolution']()).toBe(true);
|
||||||
const exactDistribution = new OracleDistribution({
|
const exactDistribution = new OracleDistribution({
|
||||||
|
|||||||
Vendored
+7
@@ -82,6 +82,7 @@ class OracleDistribution extends _base_installer_js__WEBPACK_IMPORTED_MODULE_3__
|
|||||||
possibleUrls.push(`${ORACLE_DL_BASE}/${major}/latest/jdk-${major}_${platform}-${arch}_bin.${extension}`);
|
possibleUrls.push(`${ORACLE_DL_BASE}/${major}/latest/jdk-${major}_${platform}-${arch}_bin.${extension}`);
|
||||||
}
|
}
|
||||||
const floatingUrl = isOnlyMajorProvided ? possibleUrls[0] : undefined;
|
const floatingUrl = isOnlyMajorProvided ? possibleUrls[0] : undefined;
|
||||||
|
let latestUrlNotFound = false;
|
||||||
possibleUrls.push(`${ORACLE_DL_BASE}/${major}/archive/jdk-${range}_${platform}-${arch}_bin.${extension}`);
|
possibleUrls.push(`${ORACLE_DL_BASE}/${major}/archive/jdk-${range}_${platform}-${arch}_bin.${extension}`);
|
||||||
if (parseInt(major) < 17) {
|
if (parseInt(major) < 17) {
|
||||||
throw new Error('Oracle JDK is only supported for JDK 17 and later');
|
throw new Error('Oracle JDK is only supported for JDK 17 and later');
|
||||||
@@ -90,6 +91,9 @@ class OracleDistribution extends _base_installer_js__WEBPACK_IMPORTED_MODULE_3__
|
|||||||
const response = await this.http.head(url);
|
const response = await this.http.head(url);
|
||||||
if (response.message.statusCode === _actions_http_client__WEBPACK_IMPORTED_MODULE_5__/* .HttpCodes */ .Hv.OK) {
|
if (response.message.statusCode === _actions_http_client__WEBPACK_IMPORTED_MODULE_5__/* .HttpCodes */ .Hv.OK) {
|
||||||
const floating = url === floatingUrl;
|
const floating = url === floatingUrl;
|
||||||
|
if (latestUrlNotFound) {
|
||||||
|
_actions_core__WEBPACK_IMPORTED_MODULE_0__/* .warning */ .$e(`Oracle JDK ${major} is no longer available from the latest endpoint. Falling back to its archived GA release, which may not include security updates.`);
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
url,
|
url,
|
||||||
version: range,
|
version: range,
|
||||||
@@ -100,6 +104,9 @@ class OracleDistribution extends _base_installer_js__WEBPACK_IMPORTED_MODULE_3__
|
|||||||
: undefined
|
: undefined
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
if (url === floatingUrl) {
|
||||||
|
latestUrlNotFound = true;
|
||||||
|
}
|
||||||
if (response.message.statusCode !== _actions_http_client__WEBPACK_IMPORTED_MODULE_5__/* .HttpCodes */ .Hv.NotFound) {
|
if (response.message.statusCode !== _actions_http_client__WEBPACK_IMPORTED_MODULE_5__/* .HttpCodes */ .Hv.NotFound) {
|
||||||
throw new Error(`Http request for Oracle JDK failed with status code: ${response.message.statusCode}`);
|
throw new Error(`Http request for Oracle JDK failed with status code: ${response.message.statusCode}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ export class OracleDistribution extends JavaBase {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
const floatingUrl = isOnlyMajorProvided ? possibleUrls[0] : undefined;
|
const floatingUrl = isOnlyMajorProvided ? possibleUrls[0] : undefined;
|
||||||
|
let latestUrlNotFound = false;
|
||||||
|
|
||||||
possibleUrls.push(
|
possibleUrls.push(
|
||||||
`${ORACLE_DL_BASE}/${major}/archive/jdk-${range}_${platform}-${arch}_bin.${extension}`
|
`${ORACLE_DL_BASE}/${major}/archive/jdk-${range}_${platform}-${arch}_bin.${extension}`
|
||||||
@@ -123,6 +124,11 @@ export class OracleDistribution extends JavaBase {
|
|||||||
|
|
||||||
if (response.message.statusCode === HttpCodes.OK) {
|
if (response.message.statusCode === HttpCodes.OK) {
|
||||||
const floating = url === floatingUrl;
|
const floating = url === floatingUrl;
|
||||||
|
if (latestUrlNotFound) {
|
||||||
|
core.warning(
|
||||||
|
`Oracle JDK ${major} is no longer available from the latest endpoint. Falling back to its archived GA release, which may not include security updates.`
|
||||||
|
);
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
url,
|
url,
|
||||||
version: range,
|
version: range,
|
||||||
@@ -134,6 +140,10 @@ export class OracleDistribution extends JavaBase {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (url === floatingUrl) {
|
||||||
|
latestUrlNotFound = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (response.message.statusCode !== HttpCodes.NotFound) {
|
if (response.message.statusCode !== HttpCodes.NotFound) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Http request for Oracle JDK failed with status code: ${response.message.statusCode}`
|
`Http request for Oracle JDK failed with status code: ${response.message.statusCode}`
|
||||||
|
|||||||
Reference in New Issue
Block a user