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
This commit is contained in:
John 2026-06-12 11:53:18 +00:00
parent 7d2d456be4
commit 5d3f13625c
2 changed files with 10 additions and 14 deletions

11
dist/setup/index.js vendored
View File

@ -77847,16 +77847,15 @@ class AdoptDistribution extends base_installer_1.JavaBase {
return yield this.temurinDistribution.findPackageForDownload(version); return yield this.temurinDistribution.findPackageForDownload(version);
} }
catch (error) { catch (error) {
// Only fall back to legacy AdoptOpenJDK for version-not-found errors // Log the failure but always fall back to legacy AdoptOpenJDK for resilience
if (error instanceof Error && const errorMessage = error instanceof Error ? error.message : String(error);
error.message.includes('No matching version found')) { 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 ' + 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.'); '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 { 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)}`); core.debug(`Temurin lookup failed: ${errorMessage}. Falling back to AdoptOpenJDK API.`);
throw error;
} }
} }
} }

View File

@ -71,21 +71,18 @@ export class AdoptDistribution extends JavaBase {
try { try {
return await this.temurinDistribution.findPackageForDownload(version); return await this.temurinDistribution.findPackageForDownload(version);
} catch (error) { } catch (error) {
// Only fall back to legacy AdoptOpenJDK for version-not-found errors // Log the failure but always fall back to legacy AdoptOpenJDK for resilience
if ( const errorMessage = error instanceof Error ? error.message : String(error);
error instanceof Error && if (errorMessage.includes('No matching version found')) {
error.message.includes('No matching version found')
) {
core.notice( core.notice(
'The JVM you are looking for could not be found in the Temurin repository, this likely indicates ' + '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.' '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 { } else {
// Rethrow unexpected errors to avoid masking real issues // Log other errors for debugging but gracefully fall back
core.debug( 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;
} }
} }
} }