From d049c446037d2ae2abc5cec2a039b1d2df5c9fb0 Mon Sep 17 00:00:00 2001 From: Thevakumar-Luheerathan Date: Wed, 6 Mar 2024 15:26:20 +0530 Subject: [PATCH] Fix bad-sad error --- .../src/main/java/io/ballerina/cli/cmd/ToolCommand.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/ToolCommand.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/ToolCommand.java index d8385e3a2b74..87d549c36bcb 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/ToolCommand.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/ToolCommand.java @@ -19,6 +19,7 @@ package io.ballerina.cli.cmd; import com.google.gson.Gson; +import com.google.gson.JsonElement; import com.google.gson.JsonObject; import io.ballerina.cli.BLauncherCmd; import io.ballerina.cli.utils.PrintUtils; @@ -495,7 +496,11 @@ private boolean isToolAvailableInLocalRepo(String toolId, String version) { } try (BufferedReader bufferedReader = Files.newBufferedReader(localToolJsonPath, StandardCharsets.UTF_8)) { localToolJson = gson.fromJson(bufferedReader, JsonObject.class); - JsonObject pkgDesc = localToolJson.get(toolId).getAsJsonObject(); + JsonElement localTool = localToolJson.get(toolId); + if (localTool == null) { + return false; + } + JsonObject pkgDesc = localTool.getAsJsonObject(); if (pkgDesc.isEmpty()) { return false; }