Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
throw error if version is not stable
  • Loading branch information
dmitry-shibanov committed Dec 13, 2021
commit 49b34f3f12cf8d385f9ff45d362e8f77ad3992c4
3 changes: 3 additions & 0 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13886,6 +13886,9 @@ class MicrosoftDistributions extends base_installer_1.JavaBase {
if (this.architecture !== 'x64' && this.architecture !== 'aarch64') {
throw new Error(`Unsupported architecture: ${this.architecture}`);
}
if (!this.stable) {
throw new Error('Unstable versions are not supported');
}
const availableVersionsRaw = yield this.getAvailableVersions();
const opts = this.getPlatformOption();
const availableVersions = availableVersionsRaw.map(item => ({
Expand Down
5 changes: 5 additions & 0 deletions src/distributions/microsoft/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ export class MicrosoftDistributions extends JavaBase {
if (this.architecture !== 'x64' && this.architecture !== 'aarch64') {
throw new Error(`Unsupported architecture: ${this.architecture}`);
}

if (!this.stable) {
throw new Error('Unstable versions are not supported');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the value of adding a special error message here? We only have two hardcoded versions currently. If someone requests something that's not one of those versions, we'll raise an error and show the available versions (lines 62-70 of this file).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can get ga/ea versions of java releases, but Microsoft OpenJDK builds do not have ea versions. If we pass 11-ea in java-version input, the action won't throw an error and install stable version, because the action normalizes version to 11 and set stable to the false value. For now I think we should write a condition to throw an error for ea builds.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw new Error('Unstable versions are not supported');
throw new Error('Early access versions are not supported');

While it's true that it's not a stable version, "unstable" has a stronger denotation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Thank you.

}

const availableVersionsRaw = await this.getAvailableVersions();

const opts = this.getPlatformOption();
Expand Down