diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-05-30 16:17:04 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-06-02 09:56:15 +0200 |
commit | 3b0aae00b4ce9998a63ac28b7d846d23c14e1a1d (patch) | |
tree | ac693be50dd5d87c7dd4f65a81d6811b46e73dbf | |
parent | 4ad3000721f044a1613b1d429701cd3d68b1b0b5 (diff) | |
download | sonarqube-3b0aae00b4ce9998a63ac28b7d846d23c14e1a1d.tar.gz sonarqube-3b0aae00b4ce9998a63ac28b7d846d23c14e1a1d.zip |
Fix false-positive in api/ce/is_queue_empty on mysql
-rw-r--r-- | server/sonar-server/src/main/java/org/sonar/server/ce/ws/IsQueueEmptyWs.java | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/ce/ws/IsQueueEmptyWs.java b/server/sonar-server/src/main/java/org/sonar/server/ce/ws/IsQueueEmptyWs.java index 7ae95f8dd9d..7accd1f4264 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/ce/ws/IsQueueEmptyWs.java +++ b/server/sonar-server/src/main/java/org/sonar/server/ce/ws/IsQueueEmptyWs.java @@ -24,6 +24,7 @@ import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.RequestHandler; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; +import org.sonar.api.utils.log.Loggers; import org.sonar.db.DbClient; import org.sonar.db.DbSession; @@ -69,10 +70,14 @@ public class IsQueueEmptyWs implements WebService { @Override public void handle(Request request, Response response) throws Exception { + boolean isQueueEmpty = false; try (DbSession dbSession = dbClient.openSession(false)) { - boolean isQueueEmpty = dbClient.ceQueueDao().selectAllInAscOrder(dbSession).isEmpty(); - IOUtils.write(String.valueOf(isQueueEmpty), response.stream().output(), UTF_8); + isQueueEmpty = dbClient.ceQueueDao().selectAllInAscOrder(dbSession).isEmpty(); + } catch (Exception e) { + // ignore this FP : https://gist.github.com/simonbrandhof/3d98f854d427519ef5b858a73b59585b + Loggers.get(getClass()).error("Cannot select rows from ce_queue", e); } + IOUtils.write(String.valueOf(isQueueEmpty), response.stream().output(), UTF_8); } } } |