diff options
author | Léo Geoffroy <leo.geoffroy@sonarsource.com> | 2024-04-03 10:54:18 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2024-04-03 20:02:41 +0000 |
commit | 7b5762a76af8b61a195e1209f40afd543413afaf (patch) | |
tree | 0d4239b5a64f5306091265e24570d6abfaa0f4e6 /server | |
parent | 78d6e9af1918b2d7012fbe3d27cf87c55879b1ca (diff) | |
download | sonarqube-7b5762a76af8b61a195e1209f40afd543413afaf.tar.gz sonarqube-7b5762a76af8b61a195e1209f40afd543413afaf.zip |
SONAR-21908 Fix incomplete json response on error
Diffstat (limited to 'server')
-rw-r--r-- | server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/UpgradesAction.java | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/UpgradesAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/UpgradesAction.java index 4c050dae34a..e66308cefbc 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/UpgradesAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/UpgradesAction.java @@ -117,18 +117,19 @@ public class UpgradesAction implements SystemWsAction { private void writeResponse(JsonWriter jsonWriter) { jsonWriter.beginObject(); - - Optional<UpdateCenter> updateCenterOpt = updateCenterFactory.getUpdateCenter(DO_NOT_FORCE_REFRESH); - writeUpgrades(jsonWriter, updateCenterOpt); - if (updateCenterOpt.isPresent()) { - UpdateCenter updateCenter = updateCenterOpt.get(); - writeLatestLtsVersion(jsonWriter, updateCenter); - writeLatestLtaVersion(jsonWriter, updateCenter); - jsonWriter.propDateTime(PROPERTY_UPDATE_CENTER_REFRESH, updateCenter.getDate()); - jsonWriter.prop(INSTALLED_VERSION_ACTIVE, activeVersionEvaluator.evaluateIfActiveVersion(updateCenter)); + try { + Optional<UpdateCenter> updateCenterOpt = updateCenterFactory.getUpdateCenter(DO_NOT_FORCE_REFRESH); + writeUpgrades(jsonWriter, updateCenterOpt); + if (updateCenterOpt.isPresent()) { + UpdateCenter updateCenter = updateCenterOpt.get(); + writeLatestLtsVersion(jsonWriter, updateCenter); + writeLatestLtaVersion(jsonWriter, updateCenter); + jsonWriter.propDateTime(PROPERTY_UPDATE_CENTER_REFRESH, updateCenter.getDate()); + jsonWriter.prop(INSTALLED_VERSION_ACTIVE, activeVersionEvaluator.evaluateIfActiveVersion(updateCenter)); + } + } finally { + jsonWriter.endObject(); } - - jsonWriter.endObject(); } private static void writeLatestLtsVersion(JsonWriter jsonWriter, UpdateCenter updateCenter) { |