From 5d3f13625c438f813a5a917213f7b1ea762a6786 Mon Sep 17 00:00:00 2001 From: John <1615532+johnoliver@users.noreply.github.com> Date: Fri, 12 Jun 2026 11:53:18 +0000 Subject: [PATCH] Always fall back to legacy AdoptOpenJDK but log all Temurin failures - Change error handling to gracefully fall back for all errors, not just version-not-found - Log version-not-found errors as notices with migration guidance - Log other Temurin failures as debug messages for troubleshooting - Improves resilience: users always get a result even if Temurin API has issues - Maintains visibility: failures are still logged for debugging --- dist/setup/index.js | 11 +++++------ src/distributions/adopt/installer.ts | 13 +++++-------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 0d4176d2..18c4633e 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -77847,16 +77847,15 @@ class AdoptDistribution extends base_installer_1.JavaBase { return yield this.temurinDistribution.findPackageForDownload(version); } catch (error) { - // Only fall back to legacy AdoptOpenJDK for version-not-found errors - if (error instanceof Error && - error.message.includes('No matching version found')) { + // Log the failure but always fall back to legacy AdoptOpenJDK for resilience + const errorMessage = error instanceof Error ? error.message : String(error); + if (errorMessage.includes('No matching version found')) { core.notice('The JVM you are looking for could not be found in the Temurin repository, this likely indicates ' + 'that you are using an out of date version of Java, consider updating and moving to using the Temurin distribution type in setup-java.'); } else { - // Rethrow unexpected errors to avoid masking real issues - core.debug(`Unexpected error from Temurin lookup: ${error instanceof Error ? error.message : String(error)}`); - throw error; + // Log other errors for debugging but gracefully fall back + core.debug(`Temurin lookup failed: ${errorMessage}. Falling back to AdoptOpenJDK API.`); } } } diff --git a/src/distributions/adopt/installer.ts b/src/distributions/adopt/installer.ts index a8c6f57b..edfc0f3b 100644 --- a/src/distributions/adopt/installer.ts +++ b/src/distributions/adopt/installer.ts @@ -71,21 +71,18 @@ export class AdoptDistribution extends JavaBase { try { return await this.temurinDistribution.findPackageForDownload(version); } catch (error) { - // Only fall back to legacy AdoptOpenJDK for version-not-found errors - if ( - error instanceof Error && - error.message.includes('No matching version found') - ) { + // Log the failure but always fall back to legacy AdoptOpenJDK for resilience + const errorMessage = error instanceof Error ? error.message : String(error); + if (errorMessage.includes('No matching version found')) { core.notice( 'The JVM you are looking for could not be found in the Temurin repository, this likely indicates ' + 'that you are using an out of date version of Java, consider updating and moving to using the Temurin distribution type in setup-java.' ); } else { - // Rethrow unexpected errors to avoid masking real issues + // Log other errors for debugging but gracefully fall back core.debug( - `Unexpected error from Temurin lookup: ${error instanceof Error ? error.message : String(error)}` + `Temurin lookup failed: ${errorMessage}. Falling back to AdoptOpenJDK API.` ); - throw error; } } }