aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2017-07-12 09:31:54 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2017-07-12 11:27:27 +0200
commit289be70bf6056b5f3c66a797ecab019891e731d6 (patch)
treefc7798b1aab7b05f5e326ce0071765e4e35a81a6 /server
parent8c82a4c246dc8928470ebe0a148725c7f1bd5dcd (diff)
downloadsonarqube-289be70bf6056b5f3c66a797ecab019891e731d6.tar.gz
sonarqube-289be70bf6056b5f3c66a797ecab019891e731d6.zip
Fix Quality flaws
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/project/ws/GhostsAction.java10
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/BulkChangeWsResponse.java12
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/UsersAction.java10
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/ws/ws/ResponseExampleAction.java14
4 files changed, 26 insertions, 20 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/project/ws/GhostsAction.java b/server/sonar-server/src/main/java/org/sonar/server/project/ws/GhostsAction.java
index 35a3ded8af7..4605d58e45d 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/project/ws/GhostsAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/project/ws/GhostsAction.java
@@ -100,10 +100,12 @@ public class GhostsAction implements ProjectsWsAction {
long nbOfProjects = dbClient.componentDao().countGhostProjects(dbSession, organization.getUuid(), query);
List<ComponentDto> projects = dbClient.componentDao().selectGhostProjects(dbSession, organization.getUuid(), query,
searchOptions.getOffset(), searchOptions.getLimit());
- JsonWriter json = response.newJsonWriter().beginObject();
- writeProjects(json, projects, desiredFields);
- searchOptions.writeJson(json, nbOfProjects);
- json.endObject().close();
+ try (JsonWriter json = response.newJsonWriter()) {
+ json.beginObject();
+ writeProjects(json, projects, desiredFields);
+ searchOptions.writeJson(json, nbOfProjects);
+ json.endObject();
+ }
}
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/BulkChangeWsResponse.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/BulkChangeWsResponse.java
index 066caaed104..69d6a019661 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/BulkChangeWsResponse.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/BulkChangeWsResponse.java
@@ -31,10 +31,12 @@ class BulkChangeWsResponse {
}
static void writeResponse(BulkChangeResult result, Response response) {
- JsonWriter json = response.newJsonWriter().beginObject();
- json.prop("succeeded", result.countSucceeded());
- json.prop("failed", result.countFailed());
- WebServiceEngine.writeErrors(json, result.getErrors());
- json.endObject().close();
+ try (JsonWriter json = response.newJsonWriter()) {
+ json.beginObject();
+ json.prop("succeeded", result.countSucceeded());
+ json.prop("failed", result.countFailed());
+ WebServiceEngine.writeErrors(json, result.getErrors());
+ json.endObject();
+ }
}
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/UsersAction.java b/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/UsersAction.java
index c7dc2ffba74..4cc04bd8771 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/UsersAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/UsersAction.java
@@ -92,10 +92,12 @@ public class UsersAction implements UserGroupsWsAction {
Paging paging = forPageIndex(page).withPageSize(pageSize).andTotal(total);
List<UserMembershipDto> users = dbClient.groupMembershipDao().selectMembers(dbSession, query, paging.offset(), paging.pageSize());
- JsonWriter json = response.newJsonWriter().beginObject();
- writeMembers(json, users);
- writePaging(json, paging);
- json.endObject().close();
+ try (JsonWriter json = response.newJsonWriter()) {
+ json.beginObject();
+ writeMembers(json, users);
+ writePaging(json, paging);
+ json.endObject();
+ }
}
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/ws/ws/ResponseExampleAction.java b/server/sonar-server/src/main/java/org/sonar/server/ws/ws/ResponseExampleAction.java
index 416eb31d8c1..8e461c7f853 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/ws/ws/ResponseExampleAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/ws/ws/ResponseExampleAction.java
@@ -22,6 +22,7 @@ package org.sonar.server.ws.ws;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
+import org.sonar.api.utils.text.JsonWriter;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
@@ -66,13 +67,12 @@ public class ResponseExampleAction implements WebServicesWsAction {
return;
}
- response
- .newJsonWriter()
- .beginObject()
- .prop("format", action.responseExampleFormat())
- .prop("example", action.responseExampleAsString())
- .endObject()
- .close();
+ try (JsonWriter json = response.newJsonWriter()) {
+ json.beginObject()
+ .prop("format", action.responseExampleFormat())
+ .prop("example", action.responseExampleAsString())
+ .endObject();
+ }
}
@Override