*/
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;
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())
*/
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;
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);
}