From 29994d2a4ffa03fa205d7ed674cc29cc2efb5edb Mon Sep 17 00:00:00 2001 From: Marcono1234 Date: Wed, 24 Jan 2024 00:59:14 +0100 Subject: NO-JIRA Make Gson usage more type-safe Uses `Gson.fromJson(..., TypeToken)` instead of `fromJson(..., Type)` Also replaces some usage of the deprecated `JsonParser()` constructor. --- .../main/java/org/sonar/scanner/bootstrap/DefaultScannerWsClient.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap') diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/DefaultScannerWsClient.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/DefaultScannerWsClient.java index 64f32c7fbee..7c536195a8c 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/DefaultScannerWsClient.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/DefaultScannerWsClient.java @@ -189,8 +189,7 @@ public class DefaultScannerWsClient implements ScannerWsClient { @CheckForNull private static String tryParseAsJsonError(String responseContent) { try { - JsonParser parser = new JsonParser(); - JsonObject obj = parser.parse(responseContent).getAsJsonObject(); + JsonObject obj = JsonParser.parseString(responseContent).getAsJsonObject(); JsonArray errors = obj.getAsJsonArray("errors"); List errorMessages = new ArrayList<>(); for (JsonElement e : errors) { -- cgit v1.2.3