From: Sébastien Lesaint Date: Tue, 22 Aug 2017 14:46:39 +0000 (+0200) Subject: SONAR-9283 fix dropped support of empty properties in Props X-Git-Tag: 6.6-RC1~550 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0e446b28cdda15a92d8b365bc908c8f4eda055ac;p=sonarqube.git SONAR-9283 fix dropped support of empty properties in Props --- diff --git a/server/sonar-process/src/main/java/org/sonar/process/Props.java b/server/sonar-process/src/main/java/org/sonar/process/Props.java index fd9c896089f..53cb323b365 100644 --- a/server/sonar-process/src/main/java/org/sonar/process/Props.java +++ b/server/sonar-process/src/main/java/org/sonar/process/Props.java @@ -122,10 +122,6 @@ public class Props { if (value == null) { return null; } - String trimmed = value.trim(); - if (trimmed.isEmpty()) { - return null; - } - return trimmed; + return value.trim(); } } diff --git a/server/sonar-process/src/test/java/org/sonar/process/PropsTest.java b/server/sonar-process/src/test/java/org/sonar/process/PropsTest.java index 8c7d21a6567..0a6d4311dba 100644 --- a/server/sonar-process/src/test/java/org/sonar/process/PropsTest.java +++ b/server/sonar-process/src/test/java/org/sonar/process/PropsTest.java @@ -52,8 +52,8 @@ public class PropsTest { assertThat(props.value("foo")).isEqualTo("bar"); assertThat(props.value("foo", "default value")).isEqualTo("bar"); - assertThat(props.value("blank")).isNull(); - assertThat(props.value("blank", "default value")).isEqualTo("default value"); + assertThat(props.value("blank")).isEmpty(); + assertThat(props.value("blank", "default value")).isEmpty(); assertThat(props.value("unknown")).isNull(); assertThat(props.value("unknown", "default value")).isEqualTo("default value"); } @@ -80,14 +80,12 @@ public class PropsTest { @Test @UseDataProvider("beforeAndAfterBlanks") - public void nonNullValue_throws_IAE_on_existing_key_with_blank_value(String blankBefore, String blankAfter) { + public void nonNullValue_return_empty_string_IAE_on_existing_key_with_blank_value(String blankBefore, String blankAfter) { Properties p = new Properties(); p.setProperty("blank", blankBefore + blankAfter); Props props = new Props(p); - expectedException.expect(IllegalArgumentException.class); - - props.nonNullValue("blank"); + assertThat(props.nonNullValue("blank")).isEmpty(); } @Test