Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ plugins {
def allureVersion = '2.29.1'
def aspectJVersion = '1.9.25'
def assertjVersion = '3.27.7'
def devkitmanVersion = '0.4.6'
def devkitmanVersion = '0.4.8'
def junitBomVersion = '5.14.1'
def testcontainersVersion = '2.0.2'
def jlineVersion = '3.30.5'
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/dev/jbang/cli/Jdk.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ public Integer doCall() {
if (jdk.javaHomeDir != null) {
out.print(", " + jdk.javaHomeDir);
}
if (jdk.linkedId != null) {
out.print(", link to " + jdk.linkedId);
}
if (!jdk.tags.isEmpty()) {
out.print(", " + jdk.tags);
}
Expand Down Expand Up @@ -297,7 +300,9 @@ public Integer doCall() {
}
}
jdk.uninstall();
Util.infoMsg("Uninstalled JDK:\n " + jdk.id());
if (!jdk.isInstalled()) {
Util.infoMsg("Uninstalled JDK:\n " + jdk.id());
}
return EXIT_OK;
Comment on lines +303 to 306
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Return a non-zero exit when uninstall did not actually remove the JDK.

If jdk.isInstalled() remains true after uninstall(), the command currently exits with EXIT_OK and no message. That masks a failed uninstall.

Suggested fix
 		jdk.uninstall();
-		if (!jdk.isInstalled()) {
-			Util.infoMsg("Uninstalled JDK:\n  " + jdk.id());
-		}
+		if (!jdk.isInstalled()) {
+			Util.infoMsg("Uninstalled JDK:\n  " + jdk.id());
+		} else {
+			throw new ExitException(EXIT_INVALID_INPUT, "Failed to uninstall JDK: " + jdk.id());
+		}
 		return EXIT_OK;
As per coding guidelines, "Throw `dev.jbang.cli.ExitException` for controlled exits; let picocli report parameter issues".
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (!jdk.isInstalled()) {
Util.infoMsg("Uninstalled JDK:\n " + jdk.id());
}
return EXIT_OK;
if (!jdk.isInstalled()) {
Util.infoMsg("Uninstalled JDK:\n " + jdk.id());
} else {
throw new ExitException(EXIT_INVALID_INPUT, "Failed to uninstall JDK: " + jdk.id());
}
return EXIT_OK;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/java/dev/jbang/cli/Jdk.java` around lines 303 - 306, The uninstall
flow currently returns EXIT_OK even when the JDK remains installed; update the
code in class Jdk after calling uninstall() to check jdk.isInstalled() and if it
is still true throw a dev.jbang.cli.ExitException with a non-zero exit code and
a clear error message (e.g., "Failed to uninstall JDK: <jdk.id()>"). Ensure you
use the ExitException type for controlled exits rather than returning EXIT_OK so
callers/picocli see the non-zero failure status.

}
}
Expand Down
Loading