]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9283 fix dropped support of empty properties in Props
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Tue, 22 Aug 2017 14:46:39 +0000 (16:46 +0200)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Tue, 22 Aug 2017 14:46:39 +0000 (16:46 +0200)
server/sonar-process/src/main/java/org/sonar/process/Props.java
server/sonar-process/src/test/java/org/sonar/process/PropsTest.java

index fd9c896089f2bf63375d0753498c67e911069d6c..53cb323b365eec7113e3715cd587ed11c6f588e6 100644 (file)
@@ -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();
   }
 }
index 8c7d21a656792a74f5c38e1dff37c3752af6455a..0a6d4311dba33440fc7ea495925261b6655a2c26 100644 (file)
@@ -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