From bebc9fdb1fed6713073517eb1fa9b003c7bd34ae Mon Sep 17 00:00:00 2001 From: Zipeng WU Date: Tue, 8 Dec 2020 17:15:51 +0100 Subject: [PATCH] Fix optional get without ifPresent check --- .../ce/task/projectanalysis/measure/MeasureRepositoryImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/MeasureRepositoryImpl.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/MeasureRepositoryImpl.java index 513f7481a40..3347430b736 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/MeasureRepositoryImpl.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/MeasureRepositoryImpl.java @@ -113,7 +113,7 @@ public class MeasureRepositoryImpl implements MeasureRepository { String metricKey = batchMeasure.getMetricKey(); if (reportMetricValidator.validate(metricKey)) { Metric metric = metricRepository.getByKey(metricKey); - delegate.add(component, metric, batchMeasureToMeasure.toMeasure(batchMeasure, metric).get(), OverridePolicy.DO_NOT_OVERRIDE); + batchMeasureToMeasure.toMeasure(batchMeasure, metric).ifPresent(measure -> delegate.add(component, metric, measure, OverridePolicy.DO_NOT_OVERRIDE)); } } } -- 2.39.5