From: Julien Lancelot Date: Thu, 21 Nov 2013 14:22:50 +0000 (+0100) Subject: SONAR-4775 Do not log twice time warnings X-Git-Tag: 4.1-RC1~249 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8ef7d02997f1a8c49b8030ca7f352eed14d99827;p=sonarqube.git SONAR-4775 Do not log twice time warnings --- diff --git a/sonar-core/src/main/java/org/sonar/core/technicaldebt/TechnicalDebtXMLImporter.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/TechnicalDebtXMLImporter.java index cfed80d225c..313518f77b5 100644 --- a/sonar-core/src/main/java/org/sonar/core/technicaldebt/TechnicalDebtXMLImporter.java +++ b/sonar-core/src/main/java/org/sonar/core/technicaldebt/TechnicalDebtXMLImporter.java @@ -76,7 +76,6 @@ public class TechnicalDebtXMLImporter implements ServerExtension { cursor.getStreamReader().closeCompletely(); } catch (XMLStreamException e) { - LOG.error("XML is not valid", e); messages.addErrorText("XML is not valid: " + e.getMessage()); } return model; @@ -163,16 +162,11 @@ public class TechnicalDebtXMLImporter implements ServerExtension { function.setTextValue(TechnicalDebtRequirement.FUNCTION_LINEAR); CharacteristicProperty offset = characteristic.getProperty(TechnicalDebtRequirement.PROPERTY_OFFSET); offset.setValue(0d); - - String message = String.format("Linear with threshold function is no more used, function of the requirement '%s:%s' is replaced by linear.", - characteristic.getRule().getRepositoryKey(), characteristic.getRule().getKey()); - LOG.warn(message); - messages.addWarningText(message); + messages.addWarningText(String.format("Linear with threshold function is no more used, function of the requirement '%s:%s' is replaced by linear.", + characteristic.getRule().getRepositoryKey(), characteristic.getRule().getKey())); } else if ("constant_resource".equals(function.getTextValue())) { - String message = String.format("Constant/file function is no more used, requirements '%s:%s' are ignored.", - characteristic.getRule().getRepositoryKey(), characteristic.getRule().getKey()); - LOG.warn(message); - messages.addWarningText(message); + messages.addWarningText(String.format("Constant/file function is no more used, requirements '%s:%s' are ignored.", + characteristic.getRule().getRepositoryKey(), characteristic.getRule().getKey())); return null; } } @@ -194,9 +188,7 @@ public class TechnicalDebtXMLImporter implements ServerExtension { try { value = NumberUtils.createDouble(s); } catch (NumberFormatException ex) { - String message = String.format("Cannot import value '%s' for field %s - Expected a numeric value instead", s, key); - LOG.error(message, ex); - messages.addErrorText(message); + messages.addErrorText(String.format("Cannot import value '%s' for field %s - Expected a numeric value instead", s, key)); } } else if (StringUtils.equals(node, PROPERTY_TEXT_VALUE)) { textValue = c.collectDescendantText().trim();