]> source.dussan.org Git - sonarqube.git/commitdiff
Do not hide exception when fail to close json
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 12 Jul 2016 14:00:13 +0000 (16:00 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 12 Jul 2016 14:00:13 +0000 (16:00 +0200)
sonar-plugin-api/src/main/java/org/sonar/api/utils/text/JsonWriter.java
sonar-plugin-api/src/test/java/org/sonar/api/utils/text/JsonWriterTest.java

index bea1dcc2d271cde404ca515d276493660f039d82..de3b3cd988d1554f90fb1b543b6ca4c5c799698d 100644 (file)
@@ -382,8 +382,7 @@ public class JsonWriter {
   }
 
   private static IllegalStateException rethrow(Exception e) {
-    // stacktrace is not helpful
-    throw new WriterException("Fail to write JSON: " + e.getMessage());
+    throw new WriterException("Fail to write JSON",  e);
   }
 
   @Nullable
index 8c8536204042153e4f950c46e18a45a0c1264f1f..0ed59a44c000cc4d0410035c9b33a4d17d2325b1 100644 (file)
 package org.sonar.api.utils.text;
 
 import com.google.common.collect.ImmutableMap;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.DateUtils;
-
 import java.io.IOException;
 import java.io.StringWriter;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicInteger;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.sonar.api.utils.DateUtils;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.Assert.fail;
@@ -208,7 +207,7 @@ public class JsonWriterTest {
     com.google.gson.stream.JsonWriter gson = mock(com.google.gson.stream.JsonWriter.class);
     when(gson.beginArray()).thenThrow(new IOException("the reason"));
     thrown.expect(WriterException.class);
-    thrown.expectMessage("Fail to write JSON: the reason");
+    thrown.expectMessage("Fail to write JSON");
 
     new JsonWriter(gson).beginArray();
   }