From 9a177176c182387fa6b89911eb88bab567a95a11 Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Wed, 2 Jul 2014 09:14:04 +0200 Subject: [PATCH] Fix some quality flaw --- .../org/sonar/batch/scan/measure/MeasureValueCoder.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/measure/MeasureValueCoder.java b/sonar-batch/src/main/java/org/sonar/batch/scan/measure/MeasureValueCoder.java index d3e0677e86c..7f010d97d0a 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/measure/MeasureValueCoder.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/measure/MeasureValueCoder.java @@ -69,7 +69,11 @@ class MeasureValueCoder implements ValueCoder { public Object get(Value value, Class clazz, CoderContext context) { Measure m = new Measure(); String metricKey = value.getString(); - m.setMetric(metricFinder.findByKey(metricKey)); + Metric metric = metricFinder.findByKey(metricKey); + if (metric == null) { + throw new IllegalStateException("Unknow metric with key " + metricKey); + } + m.setMetric(metric); m.setRawValue(value.isNull(true) ? null : value.getDouble()); m.setData(value.getString()); m.setDescription(value.getString()); -- 2.39.5