Source:
public String createPlotCsvFile(MetricNode metricNode) throws RuntimeException { try { Set<MetricNode> metricNodeSet = Collections.singleton(metricNode); PlotSeriesDto plot; if (metricNode instanceof PlotNode) { Map<MetricNode, PlotSeriesDto> plotsMap = plotProviderService.getPlotData(metricNodeSet); plot = plotsMap.get(metricNode); } else { Map<MetricNode, List<MetricDto>> map = metricDataService.getMetrics(metricNodeSet); List<MetricDto> metricDtos = map.get(metricNode); if (metricDtos == null || metricDtos.isEmpty()) { throw new RuntimeException("No trend plot found for " + metricNode.getDisplayName()); } List<PlotDatasetDto> plotDatasets = new ArrayList<PlotDatasetDto>(metricDtos.size()); MetricRankingProvider.sortMetrics(metricDtos); String plotHeader = metricDtos.get(0).getMetricName().getTest().getTaskName() + ", " + metricNode.getDisplayName(); for (MetricDto metricDto : metricDtos) { plotDatasets.add(metricDto.getPlotDatasetDto()); } plot = new PlotSeriesDto(plotDatasets, "Sessions", "", plotHeader); } if (plot == null) { throw new RuntimeException("could not find plot data for " + metricNode.toString()); } String sessionsPrefix = getSessionPrefix(metricNode.getMetricNameDtoList()); String fileKey = sessionsPrefix + ':' + plot.getPlotHeader(); if (fileStorage.exists(fileKey)) { return fileKey; } OutputStream out = fileStorage.create(fileKey); PlotToCsvGenerator.generateCsvFile(plot, out); return fileKey; } catch (Exception e) { throw new RuntimeException("errors while creating csv file", e); } }

Target:
public String createPlotCsvFile(MetricNode metricNode) throws RuntimeException { try { Set<MetricNode> metricNodeSet = Collections.singleton(metricNode); PlotSeriesDto plot; if (metricNode instanceof PlotNode) { Map<MetricNode, PlotSeriesDto> plotsMap = plotProviderService.getPlotData(metricNodeSet); plot = plotsMap.get(metricNode); } else { Map<MetricNode, List<MetricDto>> map = metricDataService.getMetrics(metricNodeSet); List<MetricDto> metricDtos = map.get(metricNode); if (metricDtos == null || metricDtos.isEmpty()) { throw new RuntimeException("No trend plot found for " + metricNode.getDisplayName()); } List<PlotDatasetDto> plotDatasets = new ArrayList<PlotDatasetDto>(metricDtos.size()); MetricRankingProvider.sortMetrics(metricDtos); String plotHeader = metricDtos.get(0).getMetricName().getTest().getTaskName() + ", " + metricNode.getDisplayName(); for (MetricDto metricDto : metricDtos) { plotDatasets.add(metricDto.getPlotDatasetDto()); } plot = new PlotSeriesDto(plotDatasets, "Sessions", "", plotHeader); } if (plot == null) { throw new RuntimeException("could not find plot data for " + metricNode.toString()); } String sessionsPrefix = getSessionPrefix(metricNode.getMetricNameDtoList()); String fileKey = sessionsPrefix + '-' + plot.getPlotHeader().replaceAll(",", "_"); if (fileStorage.exists(fileKey)) { return fileKey; } ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); PlotToCsvGenerator.generateCsvFile(plot, byteArrayOutputStream); byte[] fileInBytes = byteArrayOutputStream.toByteArray(); fileStorage.store(fileKey, fileInBytes); return fileKey; } catch (Exception e) { log.error("Errors while creating csv file for " + metricNode, e); throw new RuntimeException("Errors while creating csv file for " + metricNode, e); } }