diff options
author | Marcono1234 <Marcono1234@users.noreply.github.com> | 2024-01-24 00:59:14 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2024-01-29 20:03:17 +0000 |
commit | 29994d2a4ffa03fa205d7ed674cc29cc2efb5edb (patch) | |
tree | 7f26e12601a0764ada8a25e87c6f6870e2195bc6 /sonar-scanner-engine/src/main | |
parent | ae627711c4596d6b411c35fbcc163952f77bc63e (diff) | |
download | sonarqube-29994d2a4ffa03fa205d7ed674cc29cc2efb5edb.tar.gz sonarqube-29994d2a4ffa03fa205d7ed674cc29cc2efb5edb.zip |
NO-JIRA Make Gson usage more type-safe
Uses `Gson.fromJson(..., TypeToken<T>)` instead of `fromJson(..., Type)`
Also replaces some usage of the deprecated `JsonParser()` constructor.
Diffstat (limited to 'sonar-scanner-engine/src/main')
-rw-r--r-- | sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/DefaultScannerWsClient.java | 3 |
1 files changed, 1 insertions, 2 deletions
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<String> errorMessages = new ArrayList<>(); for (JsonElement e : errors) { |