]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7903 buffer stream when saving and reading reports
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 5 Aug 2016 13:38:16 +0000 (15:38 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 5 Aug 2016 13:45:01 +0000 (15:45 +0200)
server/sonar-server/src/main/java/org/sonar/server/ce/ws/SubmitAction.java
server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/ExtractReportStep.java

index f2e264c447c5ee807b43c74dde9a7aaa8143c2a0..a623c16c4ac8c938a583bc495c52b54099d430d9 100644 (file)
@@ -19,6 +19,7 @@
  */
 package org.sonar.server.ce.ws;
 
+import java.io.BufferedInputStream;
 import java.io.InputStream;
 import org.apache.commons.lang.StringUtils;
 import org.sonar.api.server.ws.Request;
@@ -81,9 +82,11 @@ public class SubmitAction implements CeWsAction {
     String projectKey = wsRequest.mandatoryParam(PARAM_PROJECT_KEY);
     String projectBranch = wsRequest.param(PARAM_PROJECT_BRANCH);
     String projectName = StringUtils.defaultIfBlank(wsRequest.param(PARAM_PROJECT_NAME), projectKey);
-    InputStream reportInput = wsRequest.paramAsInputStream(PARAM_REPORT_DATA);
 
-    CeTask task = reportSubmitter.submit(projectKey, projectBranch, projectName, reportInput);
+    CeTask task;
+    try (InputStream report = new BufferedInputStream(wsRequest.paramAsInputStream(PARAM_REPORT_DATA))) {
+      task = reportSubmitter.submit(projectKey, projectBranch, projectName, report);
+    }
 
     WsCe.SubmitResponse submitResponse = WsCe.SubmitResponse.newBuilder()
       .setTaskId(task.getUuid())
index 513bc7a2738ac5ae2a27adcc690a54e28c25dfca..7e1f131b1f9dfa4c43f4172c9c64d1da4faa9e6f 100644 (file)
  */
 package org.sonar.server.computation.task.projectanalysis.step;
 
+import java.io.BufferedInputStream;
 import java.io.File;
 import java.io.IOException;
+import java.io.InputStream;
 import java.util.Optional;
 import org.sonar.api.utils.MessageException;
 import org.sonar.api.utils.TempFolder;
@@ -57,8 +59,9 @@ public class ExtractReportStep implements ComputationStep {
       Optional<CeTaskDataDao.DataStream> opt = dbClient.ceTaskDataDao().selectData(dbSession, task.getUuid());
       if (opt.isPresent()) {
         File unzippedDir = tempFolder.newDir();
-        try (CeTaskDataDao.DataStream reportStream = opt.get()) {
-          ZipUtils.unzip(reportStream.getInputStream(), unzippedDir);
+        try (CeTaskDataDao.DataStream reportStream = opt.get();
+          InputStream zipStream = new BufferedInputStream(reportStream.getInputStream())) {
+          ZipUtils.unzip(zipStream, unzippedDir);
         } catch (IOException e) {
           throw new IllegalStateException("Fail to extract report " + task.getUuid() + " from database", e);
         }