aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine/src/main
diff options
context:
space:
mode:
authorMarcono1234 <Marcono1234@users.noreply.github.com>2024-01-24 00:59:14 +0100
committersonartech <sonartech@sonarsource.com>2024-01-29 20:03:17 +0000
commit29994d2a4ffa03fa205d7ed674cc29cc2efb5edb (patch)
tree7f26e12601a0764ada8a25e87c6f6870e2195bc6 /sonar-scanner-engine/src/main
parentae627711c4596d6b411c35fbcc163952f77bc63e (diff)
downloadsonarqube-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.java3
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) {